hook_field_widget_third_party_settings_form(\Drupal\Core\Field\WidgetInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $form_mode, $form, \Drupal\Core\Form\FormStateInterface $form_state)
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.
$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\FormDisplayOverView
Related topics
- Field Types API
- Defines field, widget, display formatter, and storage types.
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, $form, \Drupal\Core\Form\FormStateInterface $form_state) { $element = array(); // Add a 'my_setting' checkbox to the settings form for 'foo_widget' field // widgets. if ($plugin->getPluginId() == 'foo_widget') { $element['my_setting'] = array( '#type' => 'checkbox', '#title' => t('My setting'), '#default_value' => $plugin->getThirdPartySetting('my_module', 'my_setting'), ); } return $element; }
Please login to continue.