You are here

public function ShsChosenTaxonomyIndexTid::buildExposeForm in Simple hierarchical select 2.0.x

Same name and namespace in other branches
  1. 8 modules/shs_chosen/src/Plugin/views/filter/ShsChosenTaxonomyIndexTid.php \Drupal\shs_chosen\Plugin\views\filter\ShsChosenTaxonomyIndexTid::buildExposeForm()

Options form subform for exposed filter options.

Overrides TaxonomyIndexTid::buildExposeForm

See also

buildOptionsForm()

File

modules/shs_chosen/src/Plugin/views/filter/ShsChosenTaxonomyIndexTid.php, line 81

Class

ShsChosenTaxonomyIndexTid
Filter by term id using "Simple hierarchical select: chosen" widgets.

Namespace

Drupal\shs_chosen\Plugin\views\filter

Code

public function buildExposeForm(&$form, FormStateInterface $form_state) {
  parent::buildExposeForm($form, $form_state);
  $form['expose']['chosen_override'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Custom chosen settings'),
    '#default_value' => !empty($this->options['expose']['chosen_override']),
    '#description' => $this
      ->t('Override !settings made for chosen.', [
      '!settings' => Link::createFromRoute('global settings', 'chosen.admin')
        ->toString(),
    ]),
  ];
  $chosen_settings = $this->options['expose'] + $this
    ->defaultChosenSettings();
  $form['fieldsets']['#value'][] = 'chosen_settings';
  $form['expose']['chosen_settings'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Chosen overrides'),
    '#open' => TRUE,
    '#states' => [
      'invisible' => [
        'input[name="options[expose][chosen_override]"]' => [
          'checked' => FALSE,
        ],
      ],
    ],
  ];
  $form['expose']['chosen_settings']['disable_search'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Disable search box'),
    '#default_value' => $chosen_settings['disable_search'],
    '#parents' => [
      'options',
      'expose',
      'disable_search',
    ],
  ];
  $form['expose']['chosen_settings']['search_contains'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Search also in the middle of words'),
    '#default_value' => $chosen_settings['search_contains'],
    '#parents' => [
      'options',
      'expose',
      'search_contains',
    ],
  ];
  $form['expose']['chosen_settings']['placeholder_text_multiple'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Placeholder text of multiple selects'),
    '#default_value' => $chosen_settings['placeholder_text_multiple'],
    '#parents' => [
      'options',
      'expose',
      'placeholder_text_multiple',
    ],
  ];
  $form['expose']['chosen_settings']['placeholder_text_single'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Placeholder text of single selects'),
    '#default_value' => $chosen_settings['placeholder_text_single'],
    '#parents' => [
      'options',
      'expose',
      'placeholder_text_single',
    ],
  ];
  $form['expose']['chosen_settings']['no_results_text'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('No results text'),
    '#default_value' => $chosen_settings['no_results_text'],
    '#parents' => [
      'options',
      'expose',
      'no_results_text',
    ],
  ];
}