You are here

public function ListWidget::settingsForm in Select (or other) 8

Same name and namespace in other branches
  1. 4.x src/Plugin/Field/FieldWidget/ListWidget.php \Drupal\select_or_other\Plugin\Field\FieldWidget\ListWidget::settingsForm()

Returns a form to configure settings for the widget.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. The field_ui module takes care of handling submitted form values.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form definition for the widget settings.

Overrides WidgetBase::settingsForm

File

src/Plugin/Field/FieldWidget/ListWidget.php, line 37

Class

ListWidget
Plugin implementation of the 'select_or_other_list' widget.

Namespace

Drupal\select_or_other\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $form = parent::settingsForm($form, $form_state);
  $form['add_other_value_to_allowed_values'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Add entered values from the other field to the allowed values list.'),
    '#default_value' => $this
      ->getSetting('add_other_value_to_allowed_values'),
  ];
  return $form;
}