You are here

public function Name::validateExposed in Drupal 8

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

Validate the exposed handler form

Overrides HandlerBase::validateExposed

File

core/modules/user/src/Plugin/views/filter/Name.php, line 65

Class

Name
Filter handler for usernames.

Namespace

Drupal\user\Plugin\views\filter

Code

public function validateExposed(&$form, FormStateInterface $form_state) {
  if (empty($this->options['exposed'])) {
    return;
  }
  if (empty($this->options['expose']['identifier'])) {
    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->operator = $this->options['group_info']['group_items'][$input]['operator'];
    $input = $this->options['group_info']['group_items'][$input]['value'];
  }
  $uids = [];
  $values = $form_state
    ->getValue($identifier);
  if ($values && (!$this->options['is_grouped'] || $this->options['is_grouped'] && $input != 'All')) {
    foreach ($values as $value) {
      $uids[] = $value['target_id'];
    }
  }
  if ($uids) {
    $this->validated_exposed_input = $uids;
  }
}