hook_field_formatter_third_party_settings_form(\Drupal\Core\Field\FormatterInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $view_mode, $form, \Drupal\Core\Form\FormStateInterface $form_state)
Allow modules to add settings to field formatters provided by other modules.
Parameters
\Drupal\Core\Field\FormatterInterface $plugin: The instantiated field formatter plugin.
\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.
$view_mode: The entity view mode.
array $form: The (entire) configuration form array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
Return value
array Returns the form array to be built.
See also
\Drupal\field_ui\DisplayOverView
Related topics
- Field Types API
- Defines field, widget, display formatter, and storage types.
File
- core/modules/field_ui/field_ui.api.php, line 32
- Hooks provided by the Field UI module.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 | function hook_field_formatter_third_party_settings_form(\Drupal\Core\Field\FormatterInterface $plugin , \Drupal\Core\Field\FieldDefinitionInterface $field_definition , $view_mode , $form , \Drupal\Core\Form\FormStateInterface $form_state ) { $element = array (); // Add a 'my_setting' checkbox to the settings form for 'foo_formatter' field // formatters. if ( $plugin ->getPluginId() == 'foo_formatter' ) { $element [ 'my_setting' ] = array ( '#type' => 'checkbox' , '#title' => t( 'My setting' ), '#default_value' => $plugin ->getThirdPartySetting( 'my_module' , 'my_setting' ), ); } return $element ; } |
Please login to continue.