You are here

public function TaxonomyIndexTid::buildExtraOptionsForm in Views (for Drupal 7) 8.3

Provide a form for setting options.

Overrides HandlerBase::buildExtraOptionsForm

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

File

lib/Views/taxonomy/Plugin/views/filter/TaxonomyIndexTid.php, line 61
Definition of views_handler_filter_term_node_tid.

Class

TaxonomyIndexTid
Filter by term id.

Namespace

Views\taxonomy\Plugin\views\filter

Code

public function buildExtraOptionsForm(&$form, &$form_state) {
  $vocabularies = taxonomy_vocabulary_get_names();
  $options = array();
  foreach ($vocabularies as $voc) {
    $options[$voc->machine_name] = check_plain($voc->name);
  }
  if ($this->options['limit']) {

    // We only do this when the form is displayed.
    if (empty($this->options['vocabulary'])) {
      $first_vocabulary = reset($vocabularies);
      $this->options['vocabulary'] = $first_vocabulary->machine_name;
    }
    if (empty($this->definition['vocabulary'])) {
      $form['vocabulary'] = array(
        '#type' => 'radios',
        '#title' => t('Vocabulary'),
        '#options' => $options,
        '#description' => t('Select which vocabulary to show terms for in the regular options.'),
        '#default_value' => $this->options['vocabulary'],
      );
    }
  }
  $form['type'] = array(
    '#type' => 'radios',
    '#title' => t('Selection type'),
    '#options' => array(
      'select' => t('Dropdown'),
      'textfield' => t('Autocomplete'),
    ),
    '#default_value' => $this->options['type'],
  );
  $form['hierarchy'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show hierarchy in dropdown'),
    '#default_value' => !empty($this->options['hierarchy']),
    '#states' => array(
      'visible' => array(
        ':input[name="options[type]"]' => array(
          'value' => 'select',
        ),
      ),
    ),
  );
}