Field Types API
Same name in other branches
- 7.x modules/field/field.api.php \field_types
- 9 core/modules/field/field.api.php \field_types
- 10 core/modules/field/field.api.php \field_types
- 11.x core/modules/field/field.api.php \field_types
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 the class implementing \Drupal\Core\Field\FieldItemInterface::schema() method.
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
Parent topics
File
-
core/
modules/ field/ field.api.php, line 13
Functions
Title Sort descending | File name | Summary |
---|---|---|
hook_field_formatter_settings_summary_alter | core/ |
Alters the field formatter settings summary. |
hook_field_formatter_third_party_settings_form | core/ |
Allow modules to add settings to field formatters provided by other modules. |
hook_field_info_alter | core/ |
Perform alterations on Field API field types. |
hook_field_storage_config_update_forbid | core/ |
Forbid a field storage update from occurring. |
hook_field_ui_preconfigured_options_alter | core/ |
Perform alterations on preconfigured field options. |
hook_field_widget_settings_summary_alter | core/ |
Alters the field widget settings summary. |
hook_field_widget_third_party_settings_form | core/ |
Allow modules to add settings to field widgets provided by other modules. |
Classes
Title Sort descending | File name | Summary |
---|---|---|
FieldItemBase | core/ |
An entity field item. |
FieldType | core/ |
Defines a FieldType annotation object. |
FieldTypePluginManager | core/ |
Plugin manager for 'field type' plugins. |
Interfaces
Title Sort descending | File name | Summary |
---|---|---|
FieldItemInterface | core/ |
Interface for entity field items. |
FieldTypePluginManagerInterface | core/ |
Defines an interface for the field type plugin manager. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.