1. 8.5.x core/modules/field/field.api.php field_formatter
  2. 8.0.x core/modules/field/field.api.php field_formatter
  3. 8.1.x core/modules/field/field.api.php field_formatter
  4. 8.2.x core/modules/field/field.api.php field_formatter
  5. 8.3.x core/modules/field/field.api.php field_formatter
  6. 8.4.x core/modules/field/field.api.php field_formatter
  7. 8.6.x core/modules/field/field.api.php field_formatter
  8. 7.x modules/field/field.api.php field_formatter

Define Field API formatter types.

Field API formatters specify how fields are displayed when the entity to which the field is attached is displayed. Fields of a given field type may be displayed using more than one formatter. In this case, the Field UI module allows the site builder to choose which formatter to use.

Formatters are Plugins managed by the \Drupal\Core\Field\FormatterPluginManager class. A formatter is a plugin annotated with class \Drupal\Core\Field\Annotation\FieldFormatter that implements \Drupal\Core\Field\FormatterInterface (in most cases, by subclassing \Drupal\Core\Field\FormatterBase). Formatter plugins need to be in the namespace \Drupal\{your_module}\Plugin\Field\FieldFormatter.

See also

Field API

Field Types API

Field Widget API

Plugin API

Parent topics

File

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

Functions

Namesort descending Location Description
hook_field_formatter_info_alter core/modules/field/field.api.php Perform alterations on Field API formatter types.

Classes

Namesort descending Location Description
FieldFormatter core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php Defines a FieldFormatter annotation object.
FormatterBase core/lib/Drupal/Core/Field/FormatterBase.php Base class for 'Field formatter' plugin implementations.
FormatterPluginManager core/lib/Drupal/Core/Field/FormatterPluginManager.php Plugin type manager for field formatters.

Interfaces

Namesort descending Location Description
FormatterInterface core/lib/Drupal/Core/Field/FormatterInterface.php Interface definition for field formatter plugins.