Field API

Attach custom data fields to Drupal objects.

The Field API allows custom data fields to be attached to Drupal objects and takes care of storing, loading, editing, and rendering field data. Any object type (node, user, etc.) can use the Field API to make itself "fieldable" and thus allow fields to be attached to it. Other modules can provide a user interface for managing custom fields via a web browser as well as a wide and flexible variety of data type, form element, and display format capabilities.

  • Field Types API. Defines field types, widget types, and display formatters. Field modules use this API to provide field types like Text and Node Reference along with the associated form elements and display formatters.
  • Field CRUD API. Create, updates, and deletes fields, bundles (a.k.a. "content types"), and instances. Modules use this API, often in hook_install(), to create custom data structures.
  • Field Attach API. Connects object types to the Field API. Field Attach API functions load, store, generate Form API structures, display, and perform a variety of other functions for field data connected to individual objects. Fieldable object types like node and user use this API to make themselves fieldable.
  • Field Info API. Exposes information about all fields, instances, widgets, and related information defined by or with the Field API.

Constants

NameLocationDescription
FIELD_BEHAVIOR_CUSTOMmodules/field/field.moduleTODO
FIELD_BEHAVIOR_DEFAULTmodules/field/field.moduleTODO
FIELD_BEHAVIOR_NONEmodules/field/field.moduleTODO
FIELD_CARDINALITY_UNLIMITEDmodules/field/field.moduleValue for $field['cardinality'] property to indicate it can hold an unlimited number of values.
FIELD_LANGUAGE_NONEmodules/field/field.moduleThe language code assigned to untranslatable fields.
FIELD_LOAD_CURRENTmodules/field/field.moduleAge argument for loading the most recent version of an object's field data with field_attach_load().
FIELD_LOAD_REVISIONmodules/field/field.moduleAge argument for loading the version of an object's field data specified in the object with field_attach_load().
FIELD_QUERY_COMPLETEmodules/field/field.moduleCursor return value for field_attach_query() to indicate that no more data is available.
FIELD_QUERY_NO_LIMITmodules/field/field.moduleLimit argument for field_attach_query() to request all available objects instead of a limited number.

Functions

NameLocationDescription
field_accessmodules/field/field.moduleDetermine whether the user has access to a given field.
field_associate_fieldsmodules/field/field.moduleAllows a module to update the database for fields and columns it controls.
field_build_modesmodules/field/field.moduleRegistry of available build modes.
field_cache_clearmodules/field/field.moduleClear the field info and field date caches.
field_cronmodules/field/field.moduleImplement hook_cron().
field_extract_bundlemodules/field/field.moduleHelper function to extract the bundle name of from a bundle object.
field_extra_fieldsmodules/field/field.moduleRegistry of pseudo-field components in a given bundle.
field_filter_xssmodules/field/field.moduleLike filter_xss_admin(), but with a shorter list of allowed tags.
field_flush_cachesmodules/field/field.moduleImplement hook_flush_caches.
field_formatmodules/field/field.moduleFormat a field item for display.
field_get_default_valuemodules/field/field.moduleHelper function to get the default value for a field on an object.
field_has_datamodules/field/field.moduleDetermine whether a field has any data.
field_helpmodules/field/field.moduleImplement hook_help().
field_modules_disabledmodules/field/field.moduleImplement hook_modules_disabled().
field_modules_enabledmodules/field/field.moduleImplement hook_modules_enabled().
field_modules_installedmodules/field/field.moduleImplement hook_modules_installed().
field_modules_uninstalledmodules/field/field.moduleImplement hook_modules_uninstalled().
field_set_emptymodules/field/field.moduleHelper function to filter out empty values.
field_thememodules/field/field.moduleImplement hook_theme().
field_view_fieldmodules/field/field.moduleReturn a single field, fully themed with label and multiple values.
template_preprocess_fieldmodules/field/field.moduleTheme preprocess function for field.tpl.php.
template_process_fieldmodules/field/field.moduleTheme process function for field.tpl.php.
_field_extra_weights_pre_rendermodules/field/field.modulePre-render callback to adjust weights of non-field elements on objects.
_field_filter_xss_allowed_tagsmodules/field/field.moduleList of tags allowed by field_filter_xss().
_field_filter_xss_display_allowed_tagsmodules/field/field.moduleHuman-readable list of allowed tags, for display in help texts.
_field_sort_itemsmodules/field/field.moduleHelper function to sort items in a field according to user drag-n-drop reordering.
_field_sort_items_helpermodules/field/field.moduleSort function for items order. (copied form element_sort(), which acts on #weight keys)
_field_sort_items_value_helpermodules/field/field.moduleSame as above, using ['_weight']['#value']
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.