Same name and namespace in other branches
- 7.x modules/field/field.api.php \field_types
- 8.9.x core/modules/field/field.api.php \field_types
- 9 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 - Field API documentation.
Functions
Name | Location | Description |
---|---|---|
hook_field_info_alter |
core/ |
Perform alterations on Field API field types. |
hook_field_info_entity_type_ui_definitions_alter |
core/ |
Alters the UI field definitions. |
hook_field_ui_preconfigured_options_alter |
core/ |
Perform alterations on preconfigured field options. |
hook_field_storage_config_update_forbid |
core/ |
Forbid a field storage update from occurring. |
hook_field_formatter_third_party_settings_form |
core/ |
Allow modules to add settings to field formatters provided by other modules. |
hook_field_widget_third_party_settings_form |
core/ |
Allow modules to add settings to field widgets provided by other modules. |
hook_field_formatter_settings_summary_alter |
core/ |
Alters the field formatter settings summary. |
hook_field_widget_settings_summary_alter |
core/ |
Alters the field widget settings summary. |
Classes
Name | Location | Description |
---|---|---|
FieldType |
core/ |
Defines a FieldType annotation object. |
FieldItemBase |
core/ |
An entity field item. |
Interfaces
Name | Location | Description |
---|---|---|
FieldItemInterface |
core/ |
Interface for entity field items. |
FieldTypePluginManagerInterface |
core/ |
Defines an interface for the field type plugin manager. |