function hook_field_formatter_settings_form_alter

Alters the formatter settings form.

Parameters

$element: Form array.

$form_state: The form state of the (entire) configuration form.

$context: An associative array with the following elements:

  • formatter: The formatter object.
  • field: The field structure being configured.
  • instance: The instance structure being configured.
  • view_mode: The view mode being configured.
  • form: The (entire) configuration form array.

See also

\Drupal\field_ui\DisplayOverView.

Related topics

1 function implements hook_field_formatter_settings_form_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

field_test_field_formatter_settings_form_alter in drupal/core/modules/field/tests/modules/field_test/field_test.module
Implements hook_field_formatter_settings_form_alter().

File

drupal/core/modules/field_ui/field_ui.api.php, line 112
Hooks provided by the Field UI module.

Code

function hook_field_formatter_settings_form_alter(&$element, &$form_state, $context) {

  // Add a 'mysetting' checkbox to the settings form for 'foo_field' fields.
  if ($context['field']['type'] == 'foo_field') {
    $element['mysetting'] = array(
      '#type' => 'checkbox',
      '#title' => t('My setting'),
      '#default_value' => $context['formatter']
        ->getSetting('mysetting'),
    );
  }
}