You are here

public function JqueryUIMultiSelectWidget::settingsForm in jQuery UI MultiSelect Widget 8

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/JqueryUIMultiSelectWidget.php, line 46
Contains \Drupal\jquery_ui_multiselect_widget\Plugin\Field\FieldWidget\JqueryUIMultiSelectWidget.

Class

JqueryUIMultiSelectWidget
Plugin implementation of the 'boolean_checkbox' widget.

Namespace

Drupal\jquery_ui_multiselect_widget\Plugin\Field\FieldWidget

Code

public function settingsForm(array $element, FormStateInterface $form_state) {
  $field_name = $this->fieldDefinition
    ->getName();
  $element['jquery_ui_multiselect_widget_show_header'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Show header'),
    '#default_value' => $this
      ->getSetting('jquery_ui_multiselect_widget_show_header'),
  );
  $element['jquery_ui_multiselect_widget_show_filter'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Show filter'),
    '#default_value' => $this
      ->getSetting('jquery_ui_multiselect_widget_show_filter'),
  );
  $element['jquery_ui_multiselect_widget_filter_placeholder'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Filter placeholder text'),
    '#default_value' => $this
      ->getSetting('jquery_ui_multiselect_widget_filter_placeholder'),
    '#states' => [
      'visible' => array(
        ':input[name="fields[' . $field_name . '][settings_edit_form][settings][jquery_ui_multiselect_widget_show_filter]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ],
  );
  return $element;
}