function TaxonomyIndexTid::validateExposed

Same name in other branches
  1. 9 core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::validateExposed()
  2. 8.9.x core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::validateExposed()
  3. 11.x core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::validateExposed()

Overrides HandlerBase::validateExposed

File

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

Class

TaxonomyIndexTid
Filter by term id.

Namespace

Drupal\taxonomy\Plugin\views\filter

Code

public function validateExposed(&$form, FormStateInterface $form_state) {
    if (empty($this->options['exposed'])) {
        return;
    }
    $identifier = $this->options['expose']['identifier'];
    $input = $form_state->getValue($identifier);
    if ($this->options['is_grouped'] && isset($this->options['group_info']['group_items'][$input])) {
        $this->validated_exposed_input = $this->options['group_info']['group_items'][$input]['value'];
        return;
    }
    // We only validate if they've chosen the text field style.
    if ($this->options['type'] != 'textfield') {
        if ($form_state->getValue($identifier) != 'All') {
            $this->validated_exposed_input = (array) $form_state->getValue($identifier);
        }
        return;
    }
    if (empty($this->options['expose']['identifier'])) {
        return;
    }
    if ($values = $form_state->getValue($identifier)) {
        foreach ($values as $value) {
            $this->validated_exposed_input[] = $value['target_id'];
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.