Same name and namespace in other branches
  1. 8.9.x core/modules/field_ui/field_ui.api.php \hook_field_widget_third_party_settings_form()
  2. 9 core/modules/field_ui/field_ui.api.php \hook_field_widget_third_party_settings_form()

Allow modules to add settings to field widgets provided by other modules.

Parameters

\Drupal\Core\Field\WidgetInterface $plugin: The instantiated field widget plugin.

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.

string $form_mode: The entity form 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\EntityFormDisplayEditForm::thirdPartySettingsForm()

Related topics

1 function implements hook_field_widget_third_party_settings_form()

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

field_third_party_test_field_widget_third_party_settings_form in core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module
Implements hook_field_widget_third_party_settings_form().

File

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

Code

function hook_field_widget_third_party_settings_form(\Drupal\Core\Field\WidgetInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $form_mode, array $form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $element = [];

  // Add a 'my_setting' checkbox to the settings form for 'foo_widget' field
  // widgets.
  if ($plugin
    ->getPluginId() == 'foo_widget') {
    $element['my_setting'] = [
      '#type' => 'checkbox',
      '#title' => t('My setting'),
      '#default_value' => $plugin
        ->getThirdPartySetting('my_module', 'my_setting'),
    ];
  }
  return $element;
}