You are here

public function TaxonomyIndexTid::validateExposed in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::validateExposed()
  2. 10 core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::validateExposed()

Validate the exposed handler form

Overrides HandlerBase::validateExposed

File

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

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'];

  // 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'];
    }
  }
}