Field Types API

  1. drupal
    1. 8
    2. 7

Define field types, widget types, display formatter types, storage types.

The bulk of the Field Types API are related to field types. A field type represents a particular type of data (integer, string, date, etc.) that can be attached to a fieldable entity. hook_field_info() defines the basic properties of a field type, and a variety of other field hooks are called by the Field Attach API to perform field-type-specific actions.

The Field Types API also defines two kinds of pluggable handlers: widgets and formatters, which specify how the field appears in edit forms and in displayed entities. Widgets and formatters can be implemented by a field-type module for its own field types, or by a third-party module to extend the behavior of existing field types.

A third kind of pluggable handlers, storage backends, is defined by the Field Storage API.

See also

hook_field_info()

hook_field_info_alter()

hook_field_schema()

hook_field_load()

hook_field_validate()

hook_field_presave()

hook_field_insert()

hook_field_update()

hook_field_delete()

hook_field_delete_revision()

hook_field_prepare_view()

hook_field_is_empty()

hook_field_widget_info()

hook_field_formatter_info()

Functions & methods

NameDescription
hook_field_deleteDefine custom delete behavior for this module's field types.
hook_field_delete_revisionDefine custom revision delete behavior for this module's field types.
hook_field_formatter_infoExpose Field API formatter types.
hook_field_formatter_info_alterPerform alterations on Field API formatter types.
hook_field_formatter_prepare_viewAllow formatters to load information for field values being displayed.
hook_field_formatter_viewBuild a renderable array for a field value.
hook_field_infoDefine Field API field types.
hook_field_info_alterPerform alterations on Field API field types.
hook_field_insertDefine custom insert behavior for this module's field types.
hook_field_is_emptyDefine what constitutes an empty item for a field type.
hook_field_loadDefine custom load behavior for this module's field types.
hook_field_prepare_translationDefine custom prepare_translation behavior for this module's field types.
hook_field_prepare_viewPrepare field values prior to display.
hook_field_presaveDefine custom presave behavior for this module's field types.
hook_field_schemaDefine the Field API schema for a field structure.
hook_field_storage_update_fieldUpdate the storage information for a field.
hook_field_updateDefine custom update behavior for this module's field types.
hook_field_validateValidate this module's field data.
hook_field_widget_errorFlag a field-level validation error.
hook_field_widget_formReturn the form for a single field widget.
hook_field_widget_form_alterAlter forms for field widgets provided by other modules.
hook_field_widget_infoExpose Field API widget types.
hook_field_widget_info_alterPerform alterations on Field API widget types.
hook_field_widget_WIDGET_TYPE_form_alterAlter widget forms for a specific widget provided by another module.

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