function hook_field_formatter_third_party_settings_form
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.
string $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\Form\EntityViewDisplayEditForm::thirdPartySettingsForm()
Related topics
3 functions implement hook_field_formatter_third_party_settings_form()
Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.
- FieldThirdPartyTestHooks::fieldFormatterThirdPartySettingsForm in core/modules/ field/ tests/ modules/ field_third_party_test/ src/ Hook/ FieldThirdPartyTestHooks.php 
- Implements hook_field_formatter_third_party_settings_form().
- FieldThirdPartyTestHooks::fieldFormatterThirdPartySettingsFormAdditionalImplementation in core/modules/ field/ tests/ modules/ field_third_party_test/ src/ Hook/ FieldThirdPartyTestHooks.php 
- Implements hook_field_formatter_third_party_settings_form().
- field_third_party_test_field_formatter_third_party_settings_form in core/modules/ field/ tests/ modules/ field_third_party_test/ field_third_party_test.module 
- Implements hook_field_formatter_third_party_settings_form().
2 invocations of hook_field_formatter_third_party_settings_form()
- EntityViewDisplayEditForm::thirdPartySettingsForm in core/modules/ field_ui/ src/ Form/ EntityViewDisplayEditForm.php 
- Adds the widget or formatter third party settings forms.
- FieldBlock::thirdPartySettingsForm in core/modules/ layout_builder/ src/ Plugin/ Block/ FieldBlock.php 
- Adds the formatter third party settings forms.
File
- 
              core/modules/ field_ui/ field_ui.api.php, line 32 
Code
function hook_field_formatter_third_party_settings_form(\Drupal\Core\Field\FormatterInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $view_mode, array $form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $element = [];
  // Add a 'my_setting' checkbox to the settings form for 'foo_formatter' field
  // formatters.
  if ($plugin->getPluginId() == 'foo_formatter') {
    $element['my_setting'] = [
      '#type' => 'checkbox',
      '#title' => t('My setting'),
      '#default_value' => $plugin->getThirdPartySetting('my_module', 'my_setting'),
    ];
  }
  return $element;
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
