Field Attach API

  1. drupal
    1. drupal7

Operate on Field API data attached to Drupal objects.

Field Attach API functions load, store, generate Form API structures, display, and perform a vareity of other functions for field data connected to individual objects.

Field Attach API functions generally take $obj_type and $object arguments along with additional function-specific arguments. $obj_type is the type of the fieldable entity, such as 'node' or 'user', and $object is the object itself. An individual object's bundle, if any, is read from the object's bundle key property identified by hook_fieldable_info() for $obj_type.

Fieldable types call Field Attach API functions during their own API calls; for example, node_load() calls field_attach_load(). A fieldable type is not required to use all of the Field Attach API functions.

Most Field Attach API functions define a corresponding hook function that allows any module to act on Field Attach operations for any object after the operation is complete, and access or modify all the field, form, or display data for that object and operation. For example, field_attach_view() invokes hook_field_attach_view_alter(). These all-module hooks are distinct from those of the Field Types API, such as hook_field_load(), that are only invoked for the module that defines a specific field type.

field_attach_load(), field_attach_insert(), and field_attach_update() also define pre-operation hooks, e.g. hook_field_attach_pre_load(). These hooks run before the corresponding Field Storage API and Field Type API operations. They allow modules to define additional storage locations (e.g. denormalizing, mirroring) for field data on a per-field basis. They also allow modules to take over field storage completely by instructing other implementations of the same hook and the Field Storage API itself not to operate on specified fields.

The pre-operation hooks do not make the Field Storage API irrelevant. The Field Storage API is essentially the "fallback mechanism" for any fields that aren't being intercepted explicitly by pre-operation hooks.

Funktionen & Methoden

NameBeschreibung
field_attach_create_bundleNotify field.module that a new bundle was created.
field_attach_deleteDelete field data for an existing object. This deletes all revisions of field data for the object.
field_attach_delete_bundleNotify field.module the a bundle was deleted.
field_attach_delete_revisionDelete field data for a single revision of an existing object. The passed object must have a revision id attribute.
field_attach_extract_idsHelper function to extract id, vid, and bundle name from an object.
field_attach_formAdd form elements for all fields for an object to a form structure.
field_attach_form_validatePerform field validation against form-submitted field values.
field_attach_insertSave field data for a new object.
field_attach_loadLoad all fields for the most current version of each of a set of objects of a single object type.
field_attach_load_revisionLoad all fields for a previous version of each of a set of objects of a single object type.
field_attach_prepare_translationImplementation of hook_node_prepare_translation.
field_attach_preprocessTo be called in entity preprocessor.
field_attach_presavePerform necessary operations just before fields data get saved.
field_attach_rename_bundleNotify field.module that a bundle was renamed.
field_attach_submitPerform necessary operations on field data submitted by a form.
field_attach_updateSave field data for an existing object.
field_attach_validatePerform field validation against the field data in an object.
field_attach_viewGenerate and return a structured content array tree suitable for drupal_render() for all of the fields on an object. The format of each field's rendered content depends on the display formatter and its settings.
hook_field_attach_create_bundleAct on field_attach_create_bundle.
hook_field_attach_deleteAct on field_attach_delete.
hook_field_attach_delete_bundleAct on field_attach_delete_bundle.
hook_field_attach_delete_revisionAct on field_attach_delete_revision.
hook_field_attach_formAct on field_attach_form.
hook_field_attach_loadAct on field_attach_load.
hook_field_attach_presaveAct on field_attach_presave.
hook_field_attach_pre_insertAct on field_attach_insert.
hook_field_attach_pre_loadAct on field_attach_pre_load.
hook_field_attach_pre_updateAct on field_attach_update.
hook_field_attach_submitAct on field_attach_submit.
hook_field_attach_validateAct on field_attach_validate.
hook_field_attach_view_alterAct on field_attach_view.
hook_field_rename_bundleAct on field_attach_rename_bundle.
_field_invokeInvoke a field hook.
_field_invoke_defaultInvoke field.module's version of a field hook.
_field_invoke_multipleInvoke a field operation across fields on multiple objects.
_field_invoke_multiple_defaultInvoke field.module's version of a field hook on multiple objects.

modules/field/field.attach.inc, line 79

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