8.3.x TaxonomyIndexTid.php public TaxonomyIndexTid::buildExtraOptionsForm(&$form, FormStateInterface $form_state)
8.0.x TaxonomyIndexTid.php public TaxonomyIndexTid::buildExtraOptionsForm(&$form, FormStateInterface $form_state)
8.1.x TaxonomyIndexTid.php public TaxonomyIndexTid::buildExtraOptionsForm(&$form, FormStateInterface $form_state)
8.2.x TaxonomyIndexTid.php public TaxonomyIndexTid::buildExtraOptionsForm(&$form, FormStateInterface $form_state)
8.4.x TaxonomyIndexTid.php public TaxonomyIndexTid::buildExtraOptionsForm(&$form, FormStateInterface $form_state)

Provide a form for setting options.

Overrides HandlerBase::buildExtraOptionsForm

1 call to TaxonomyIndexTid::buildExtraOptionsForm()
TaxonomyIndexTidDepth::buildExtraOptionsForm in core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php
Provide a form for setting options.
1 method overrides TaxonomyIndexTid::buildExtraOptionsForm()
TaxonomyIndexTidDepth::buildExtraOptionsForm in core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php
Provide a form for setting options.

File

core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php, line 106

Class

TaxonomyIndexTid
Filter by term id.

Namespace

Drupal\taxonomy\Plugin\views\filter

Code

public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
  $vocabularies = $this->vocabularyStorage->loadMultiple();
  $options = array();
  foreach ($vocabularies as $voc) {
    $options[$voc->id()] = $voc->label();
  }

  if ($this->options['limit']) {
    // We only do this when the form is displayed.
    if (empty($this->options['vid'])) {
      $first_vocabulary = reset($vocabularies);
      $this->options['vid'] = $first_vocabulary->id();
    }

    if (empty($this->definition['vocabulary'])) {
      $form['vid'] = array(
        '#type' => 'radios',
        '#title' => $this->t('Vocabulary'),
        '#options' => $options,
        '#description' => $this->t('Select which vocabulary to show terms for in the regular options.'),
        '#default_value' => $this->options['vid'],
      );
    }
  }

  $form['type'] = array(
    '#type' => 'radios',
    '#title' => $this->t('Selection type'),
    '#options' => array('select' => $this->t('Dropdown'), 'textfield' => $this->t('Autocomplete')),
    '#default_value' => $this->options['type'],
  );

  $form['hierarchy'] = array(
    '#type' => 'checkbox',
    '#title' => $this->t('Show hierarchy in dropdown'),
    '#default_value' => !empty($this->options['hierarchy']),
    '#states' => array(
      'visible' => array(
        ':input[name="options[type]"]' => array('value' => 'select'),
      ),
    ),
  );
}