hook_fieldable_info

  1. drupal
    1. drupal7
Versionen
drupal7 hook_fieldable_info()

Inform the Field API about one or more fieldable types.

Inform the Field API about one or more fieldable types, (object types to which fields can be attached).

Rückgabewert

An array whose keys are fieldable object type names and whose values identify properties of those types that the Field system needs to know about:

name: The human-readable name of the type. id key: The object property that contains the primary id for the object. Every object passed to the Field API must have this property and its value must be numeric. revision key: The object property that contains the revision id for the object, or NULL if the object type is not versioned. The Field API assumes that all revision ids are unique across all instances of a type; this means, for example, that every object's revision ids cannot be 0, 1, 2, ... bundle key: The object property that contains the bundle name for the object (bundle name is what nodes call "content type"). The bundle name defines which fields are connected to the object. cacheable: A boolean indicating whether Field API should cache loaded fields for each object, reducing the cost of field_attach_load(). bundles: An array of all existing bundle names for this object type. TODO: Define format. TODO: I'm unclear why we need this.

Code

modules/field/field.api.php, line 39

<?php
function hook_fieldable_info() {
  $return = array(
    'node' => array(
      'name' => t('Node'),
      'id key' => 'nid',
      'revision key' => 'vid',
      'bundle key' => 'type',
      // Node.module handles its own caching.
      'cacheable' => FALSE,
      // Bundles must provide human readable name so
      // we can create help and error messages about them.
      'bundles' => node_get_types('names'),
    ),
  );
  return $return;
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen