/Drupal 8

Field Types API

Defines field, widget, display formatter, and storage types.

In the Field API, each field has a type, which determines what kind of data (integer, string, date, etc.) the field can hold, which settings it provides, and so on. The data type(s) accepted by a field are defined in hook_field_schema().

Field types are plugins annotated with class \Drupal\Core\Field\Annotation\FieldType, and implement plugin interface \Drupal\Core\Field\FieldItemInterface. Field Type plugins are managed by the \Drupal\Core\Field\FieldTypePluginManager class. Field type classes usually extend base class \Drupal\Core\Field\FieldItemBase. Field-type plugins need to be in the namespace \Drupal\{your_module}\Plugin\Field\FieldType. See the Plugin API topic for more information on how to define plugins.

The Field Types API also defines two kinds of pluggable handlers: widgets and formatters. Widgets specify how the field appears in edit forms, while formatters specify how the field appears in displayed entities.

See Field API for information about the other parts of the Field API.

See also

Field API

Field Widget API

Field Formatter API

Plugin API

Parent topics

Define functions that alter the behavior of Drupal core.


core/modules/field/field.api.php, line 13
Field API documentation.


Name Location Description
hook_field_formatter_settings_summary_alter core/modules/field_ui/field_ui.api.php Alters the field formatter settings summary.
hook_field_formatter_third_party_settings_form core/modules/field_ui/field_ui.api.php Allow modules to add settings to field formatters provided by other modules.
hook_field_info_alter core/modules/field/field.api.php Perform alterations on Field API field types.
hook_field_storage_config_update_forbid core/modules/field/field.api.php Forbid a field storage update from occurring.
hook_field_widget_settings_summary_alter core/modules/field_ui/field_ui.api.php Alters the field widget settings summary.
hook_field_widget_third_party_settings_form core/modules/field_ui/field_ui.api.php Allow modules to add settings to field widgets provided by other modules.


Name Location Description
FieldItemBase core/lib/Drupal/Core/Field/FieldItemBase.php An entity field item.
FieldType core/lib/Drupal/Core/Field/Annotation/FieldType.php Defines a FieldType annotation object.
FieldTypePluginManager core/lib/Drupal/Core/Field/FieldTypePluginManager.php Plugin manager for 'field type' plugins.


Name Location Description
FieldItemInterface core/lib/Drupal/Core/Field/FieldItemInterface.php Interface for entity field items.
FieldTypePluginManagerInterface core/lib/Drupal/Core/Field/FieldTypePluginManagerInterface.php Defines an interface for the field type plugin manager.

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.