Field Attach API

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.

Functions

NameLocationDescription
field_attach_create_bundlemodules/field/field.attach.incNotify field.module that a new bundle was created.
field_attach_deletemodules/field/field.attach.incDelete field data for an existing object. This deletes all revisions of field data for the object.
field_attach_delete_bundlemodules/field/field.attach.incNotify field.module the a bundle was deleted.
field_attach_delete_revisionmodules/field/field.attach.incDelete field data for a single revision of an existing object. The passed object must have a revision id attribute.
field_attach_extra_weightmodules/field/field.attach.incRetrieve the user-defined weight for a 'pseudo-field' component.
field_attach_formmodules/field/field.attach.incAdd form elements for all fields for an object to a form structure.
field_attach_form_validatemodules/field/field.attach.incPerform field validation against form-submitted field values.
field_attach_insertmodules/field/field.attach.incSave field data for a new object.
field_attach_loadmodules/field/field.attach.incLoad all fields for the most current version of each of a set of objects of a single object type.
field_attach_load_revisionmodules/field/field.attach.incLoad all fields for a previous version of each of a set of objects of a single object type.
field_attach_prepare_translationmodules/field/field.attach.incImplement hook_node_prepare_translation.
field_attach_prepare_viewmodules/field/field.attach.incAllow formatters to act on fieldable objects prior to rendering.
field_attach_preprocessmodules/field/field.attach.incPopulate the template variables with the field values available for rendering.
field_attach_presavemodules/field/field.attach.incPerform necessary operations just before fields data get saved.
field_attach_querymodules/field/field.attach.incRetrieve objects matching a given set of conditions.
field_attach_query_revisionsmodules/field/field.attach.incRetrieve object revisions matching a given set of conditions.
field_attach_rename_bundlemodules/field/field.attach.incNotify field.module that a bundle was renamed.
field_attach_submitmodules/field/field.attach.incPerform necessary operations on field data submitted by a form.
field_attach_updatemodules/field/field.attach.incSave field data for an existing object.
field_attach_validatemodules/field/field.attach.incPerform field validation against the field data in an object.
field_attach_viewmodules/field/field.attach.incGenerate 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_bundlemodules/field/field.api.phpAct on field_attach_create_bundle.
hook_field_attach_deletemodules/field/field.api.phpAct on field_attach_delete.
hook_field_attach_delete_bundlemodules/field/field.api.phpAct on field_attach_delete_bundle.
hook_field_attach_delete_revisionmodules/field/field.api.phpAct on field_attach_delete_revision.
hook_field_attach_formmodules/field/field.api.phpAct on field_attach_form.
hook_field_attach_insertmodules/field/field.api.phpAct on field_attach_insert.
hook_field_attach_loadmodules/field/field.api.phpAct on field_attach_load.
hook_field_attach_preprocess_altermodules/field/field.api.phpAct on field_attach_preprocess.
hook_field_attach_presavemodules/field/field.api.phpAct on field_attach_presave.
hook_field_attach_rename_bundlemodules/field/field.api.phpAct on field_attach_rename_bundle.
hook_field_attach_submitmodules/field/field.api.phpAct on field_attach_submit.
hook_field_attach_updatemodules/field/field.api.phpAct on field_attach_update.
hook_field_attach_validatemodules/field/field.api.phpAct on field_attach_validate.
hook_field_attach_view_altermodules/field/field.api.phpAct on field_attach_view.
_field_invokemodules/field/field.attach.incInvoke a field hook.
_field_invoke_defaultmodules/field/field.attach.incInvoke field.module's version of a field hook.
_field_invoke_multiplemodules/field/field.attach.incInvoke a field hook across fields on multiple objects.
_field_invoke_multiple_defaultmodules/field/field.attach.incInvoke field.module's version of a field hook on multiple objects.
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.