function Equality::valueForm

Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/filter/Equality.php \Drupal\views\Plugin\views\filter\Equality::valueForm()
  2. 10 core/modules/views/src/Plugin/views/filter/Equality.php \Drupal\views\Plugin\views\filter\Equality::valueForm()
  3. 8.9.x core/modules/views/src/Plugin/views/filter/Equality.php \Drupal\views\Plugin\views\filter\Equality::valueForm()
  4. main core/modules/views/src/Plugin/views/filter/Equality.php \Drupal\views\Plugin\views\filter\Equality::valueForm()

Provide a simple textfield for equality.

Overrides FilterPluginBase::valueForm

File

core/modules/views/src/Plugin/views/filter/Equality.php, line 36

Class

Equality
Simple filter to handle equal to / not equal to filters.

Namespace

Drupal\views\Plugin\views\filter

Code

protected function valueForm(&$form, FormStateInterface $form_state) {
  $form['value'] = [
    '#type' => 'textfield',
    '#title' => $this->t('Value'),
    '#size' => 30,
    '#default_value' => $this->value,
  ];
  if ($form_state->get('exposed')) {
    $identifier = $this->options['expose']['identifier'];
    $user_input = $form_state->getUserInput();
    if (!isset($user_input[$identifier])) {
      $user_input[$identifier] = $this->value;
      $form_state->setUserInput($user_input);
    }
  }
}

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