You are here

public function ExposedFormPluginBase::buildOptionsForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase::buildOptionsForm()

Provide a form to edit options for this plugin.

Overrides PluginBase::buildOptionsForm

1 call to ExposedFormPluginBase::buildOptionsForm()
InputRequired::buildOptionsForm in core/modules/views/src/Plugin/views/exposed_form/InputRequired.php
Provide a form to edit options for this plugin.
1 method overrides ExposedFormPluginBase::buildOptionsForm()
InputRequired::buildOptionsForm in core/modules/views/src/Plugin/views/exposed_form/InputRequired.php
Provide a form to edit options for this plugin.

File

core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php, line 41

Class

ExposedFormPluginBase
Base class for Views exposed filter form plugins.

Namespace

Drupal\views\Plugin\views\exposed_form

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['submit_button'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Submit button text'),
    '#default_value' => $this->options['submit_button'],
    '#required' => TRUE,
  ];
  $form['reset_button'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Include reset button (resets all applied exposed filters)'),
    '#default_value' => $this->options['reset_button'],
  ];
  $form['reset_button_label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Reset button label'),
    '#description' => $this
      ->t('Text to display in the reset button of the exposed form.'),
    '#default_value' => $this->options['reset_button_label'],
    '#required' => TRUE,
    '#states' => [
      'invisible' => [
        'input[name="exposed_form_options[reset_button]"]' => [
          'checked' => FALSE,
        ],
      ],
    ],
  ];
  $form['exposed_sorts_label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Exposed sorts label'),
    '#default_value' => $this->options['exposed_sorts_label'],
    '#required' => TRUE,
  ];
  $form['expose_sort_order'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Allow people to choose the sort order'),
    '#description' => $this
      ->t('If sort order is not exposed, the sort criteria settings for each sort will determine its order.'),
    '#default_value' => $this->options['expose_sort_order'],
  ];
  $form['sort_asc_label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label for ascending sort'),
    '#default_value' => $this->options['sort_asc_label'],
    '#required' => TRUE,
    '#states' => [
      'visible' => [
        'input[name="exposed_form_options[expose_sort_order]"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $form['sort_desc_label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label for descending sort'),
    '#default_value' => $this->options['sort_desc_label'],
    '#required' => TRUE,
    '#states' => [
      'visible' => [
        'input[name="exposed_form_options[expose_sort_order]"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
}