You are here

public function TaxonomyIndexTid::validateExposed in Drupal 10

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

File

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

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