You are here

public function Tid::buildOptionsForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php \Drupal\taxonomy\Plugin\views\argument_default\Tid::buildOptionsForm()

Provide the default form for setting options.

Overrides ArgumentDefaultPluginBase::buildOptionsForm

File

core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php, line 116
Contains \Drupal\taxonomy\Plugin\views\argument_default\Tid.

Class

Tid
Taxonomy tid default argument.

Namespace

Drupal\taxonomy\Plugin\views\argument_default

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  $form['term_page'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Load default filter from term page'),
    '#default_value' => $this->options['term_page'],
  );
  $form['node'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Load default filter from node page, that\'s good for related taxonomy blocks'),
    '#default_value' => $this->options['node'],
  );
  $form['limit'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Limit terms by vocabulary'),
    '#default_value' => $this->options['limit'],
    '#states' => array(
      'visible' => array(
        ':input[name="options[argument_default][taxonomy_tid][node]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $options = array();
  $vocabularies = $this->vocabularyStorage
    ->loadMultiple();
  foreach ($vocabularies as $voc) {
    $options[$voc
      ->id()] = $voc
      ->label();
  }
  $form['vids'] = array(
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Vocabularies'),
    '#options' => $options,
    '#default_value' => $this->options['vids'],
    '#states' => array(
      'visible' => array(
        ':input[name="options[argument_default][taxonomy_tid][limit]"]' => array(
          'checked' => TRUE,
        ),
        ':input[name="options[argument_default][taxonomy_tid][node]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['anyall'] = array(
    '#type' => 'radios',
    '#title' => $this
      ->t('Multiple-value handling'),
    '#default_value' => $this->options['anyall'],
    '#options' => array(
      ',' => $this
        ->t('Filter to items that share all terms'),
      '+' => $this
        ->t('Filter to items that share any term'),
    ),
    '#states' => array(
      'visible' => array(
        ':input[name="options[argument_default][taxonomy_tid][node]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
}