Startseite
  • » Home
  • » Handbuch & FAQ
  • » Forum
  • » Übersetzungsserver
  • » Suche
Startseite › Forum › Drupalcenter.de › Module › Modul-Entwicklung ›

Custom entity mit entity api, Felderproblem aber ich weiß nicht wo!

Eingetragen von maen (547)
am 10.09.2014 - 13:14 Uhr in
  • Modul-Entwicklung
  • Drupal 7.x

Ich habe ein test Module mit Namen demo, in dem ich ein Custom Entity mit Namen Projekt habe. Das Ding kan das volle CRUD und ist in views integriert. Läuft sozusagen.

Aber:
Ich möchte das als Entity Reference mit dem Modul Inline Entity Form integrieren, was laut allgemeiner Aussage in der README des Moduls auch möglich sein soll.

Irgendwie habe ich aber ein Feld Problem, da die Funktion des Moduls "tableFields", die dafür zuständig ist die entsprechenden Felder der Entity zu verarbeiten, nichts beim debuggen auswirft.

Zur Funktion steht im Modul folgendes:

Zitat:

* Returns an array of fields used to represent an entity in the IEF table.
*
* The fields can be either Field API fields or properties defined through
* hook_entity_property_info().
*
* Modules can alter the output of this method through
* hook_inline_entity_form_table_fields_alter().
*

Aber nix! Alle jetzt vorkommenden Codes stehen direkt in der demo.module:

/**
* Implements hook_entity_property_info().
*/
function demo_entity_property_info() {
  $info = array();
$info['project']['properties']['id'] = array(
    'label' => t('Project ID'),
    'description' => t('The ID of the project.'),
    'type' => 'integer',
    'schema field' => 'id',
  );
  $info['project']['properties']['name'] = array(
    'label' => t('Project name'),
    'description' => t('Name of the project.'),
    'type' => 'text',
    'schema field' => 'name',
  );
  $info['project']['properties']['description'] = array(
    'label' => t('Project description'),
    'description' => t('Description of the project.'),
    'type' => 'text',
    'schema field' => 'description',
  );
  $info['project']['properties']['deadline'] = array(
    'label' => t('Deadline'),
    'description' => t('Project deadline.'),
    'type' => 'date',
    'schema field' => 'deadline',
  );
  return $info;
}

Der Code läuft weil ich damit auch views ansprechen kann.

Dann dachte ich lese ich halt mal das gesamte Internet durch, was es noch sein könnte. Deshalb kam ich dann auf die Idee die Felder noch mal in drupal förmlich anzumelden.

Habe es testweise für ein Feld gemacht:

/**
* Implements hook_field_info to make it work with Entity Meta Wrappers
* Provides the description of the field.
*/
function demo_field_info() {
  $demo_fields = array(
  // We name our field as the associative name of the array.
    'name' => array(
      'label' => t('Project name'),
      'description' => t('Name of the project.'),
      'settings' => array('max_length' => 255),
      'instance_settings' => array('text_processing' => 0),
      'default_widget' => 'text_textfield',
      'default_formatter' => 'text_default',
      'property_type' => 'text', // we add the propert type here
    ),
  );
  return $demo_fields;
}

Wenn ich aber den debugger drüber laufen lasse wird die Funktion weiter tapfer ignoriert. Trotzdem habe ich sie mal überschrieben in der Hoffnung dass das was nützt. Auf die Idee bin ich durch das line_item Modul gekommen für commerce:

/**
    * Overrides EntityInlineEntityFormController::tableFields().
    */
    public function tableFields($bundles) {
       $fields = array();
       $fields['project']['properties']['id'] = array(
       'label' => t('Project ID'),
       'description' => t('The ID of the project.'),
       'type' => 'integer',
       'schema field' => 'id',
     );
       $fields['project']['properties']['name'] = array(
       'label' => t('Project name'),
       'description' => t('Name of the project.'),
       'type' => 'text',
       'schema field' => 'name',
     );
       $fields['project']['properties']['description'] = array(
       'label' => t('Project description'),
       'description' => t('Description of the project.'),
       'type' => 'text',
       'schema field' => 'description',
     );
       $fields['project']['properties']['deadline'] = array(
       'label' => t('Deadline'),
       'description' => t('Project deadline.'),
       'type' => 'date',
       'schema field' => 'deadline',
     );
       return $fields;
}

Dann immer noch nix. So dachte ich mir, ignoriere das mal und baue ne form, vielleicht kriege ich darin dann die nötigen Felder zu Gesicht:

    /**
   * Overrides EntityInlineEntityFormController::entityForm().
   */
  public function entityForm($entity_form, &$form_state) {
      $term = $entity_form['#entity'];
      return 'is mir egal';
  }
}

Daher denke ich dass ich irgendwas bei der Erstellung der custom entity übersehen habe. Hat da jemand Efahrung oder eine Idee?

Danke vorab,

Marc

‹ [gelöst] Forms Drupal 7 create Table Output with Submit Form "Newsletter Subscription" Eigenes Modul verursacht JavaScript Fehler in IMCE ›
  • Anmelden oder Registrieren um Kommentare zu schreiben

Benutzeranmeldung

  • Registrieren
  • Neues Passwort anfordern

Aktive Forenthemen

  • Canvas Palette: Eine fertige Komponentenbibliothek für Drupal Canvas
  • Hilfe zu Updates oder Composer
  • Vergleich Drupal und Contao
  • [geloest] Blocks in Bootstrap nebeneinander darstellen und nicht untereinander
  • DrupalCamp Frankfurt 27-28 November 2026
  • Bitte mein Bentzerkonto löschen
  • Beim Aufruf einiger Inhalte erhalte ich folgende Fehlermeldung
  • Neuinstallation: vermutlich ein rewrite-Problem
  • Drupal CMS installieren
  • [erledigt]MP3 in Drupal 10 einbinden
  • (gelöst)Drupal 11 installieren
  • Titel ausblenden
Weiter

Neue Kommentare

  • anyone has a working Betaflight mirror right now?
    vor 1 Tag 3 Stunden
  • Vielen Dank für Ihren
    vor 1 Tag 8 Stunden
  • Composer ist sehr ratsam
    vor 3 Tagen 7 Stunden
  • Vielen Dank für den
    vor 5 Tagen 17 Stunden
  • Die alten CMS Vergleiche von contentmanager.de
    vor 6 Tagen 5 Stunden
  • Gut gemacht
    vor 6 Tagen 6 Stunden
  • Layout Builder etc. z.B. für Landing Pages
    vor 6 Tagen 6 Stunden
  • Links
    vor 1 Woche 1 Tag
  • Moin,wow, sehr gutes
    vor 1 Woche 2 Tagen
  • Dass ist eine spannende
    vor 1 Woche 3 Tagen

Statistik

Beiträge im Forum: 250314
Registrierte User: 20559

Neue User:

  • Cruzorerm
  • Plandkeews
  • Tepkugem

» Alle User anzeigen

User nach Punkten sortiert:
wla9466
stBorchert6003
quiptime4972
Tobias Bähr4019
bv3924
ronald3857
md3717
Thoor3678
Alexander Langer3416
Exterior2903
» User nach Punkten
Zur Zeit sind 0 User und 15 Gäste online.

Hauptmenü

  • » Home
  • » Handbuch & FAQ
  • » Forum
  • » Übersetzungsserver
  • » Suche

Quicklinks I

  • Infos
  • Drupal Showcase
  • Installation
  • Update
  • Forum
  • Team
  • Verhaltensregeln

Quicklinks II

  • Drupal Jobs
  • FAQ
  • Drupal-Kochbuch
  • Best Practice - Drupal Sites - Guidelines
  • Drupal How To's

Quicklinks III

  • Tipps & Tricks
  • Drupal Theme System
  • Theme Handbuch
  • Leitfaden zur Entwicklung von Modulen

RSS & Twitter

  • Drupal Planet deutsch
  • RSS Feed News
  • RSS Feed Planet
  • Twitter Drupalcenter
Drupalcenter Team | Impressum & Datenschutz | Kontakt
Angetrieben von Drupal | Drupal is a registered trademark of Dries Buytaert.
Drupal Initiative - Drupal Association