protected function Name::valueForm

Options form subform for setting options.

This should be overridden by all child classes and it must define $form['value']

Overrides InOperator::valueForm

See also

buildOptionsForm()

File

drupal/core/modules/user/lib/Drupal/user/Plugin/views/filter/Name.php, line 24
Definition of Drupal\user\Plugin\views\filter\Name.

Class

Name
Filter handler for usernames.

Namespace

Drupal\user\Plugin\views\filter

Code

protected function valueForm(&$form, &$form_state) {
  $values = array();
  if ($this->value) {
    $result = entity_load_multiple_by_properties('user', array(
      'uid' => $this->value,
    ));
    foreach ($result as $account) {
      if ($account
        ->id()) {
        $values[] = $account->name->value;
      }
      else {
        $values[] = 'Anonymous';

        // Intentionally NOT translated.
      }
    }
  }
  sort($values);
  $default_value = implode(', ', $values);
  $form['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Usernames'),
    '#description' => t('Enter a comma separated list of user names.'),
    '#default_value' => $default_value,
    '#autocomplete_path' => 'user/autocomplete/anonymous',
  );
  if (!empty($form_state['exposed']) && !isset($form_state['input'][$this->options['expose']['identifier']])) {
    $form_state['input'][$this->options['expose']['identifier']] = $default_value;
  }
}