function Date::validateOptionsForm

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date::validateOptionsForm()
  2. 8.9.x core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date::validateOptionsForm()
  3. 10 core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date::validateOptionsForm()

Simple validate handler.

Parameters

array $form: An alterable, associative array containing the structure of the form, passed by reference.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FilterPluginBase::validateOptionsForm

File

core/modules/views/src/Plugin/views/filter/Date.php, line 49

Class

Date
Filter to handle dates stored as a timestamp.

Namespace

Drupal\views\Plugin\views\filter

Code

public function validateOptionsForm(&$form, FormStateInterface $form_state) {
  parent::validateOptionsForm($form, $form_state);
  if (!empty($this->options['exposed']) && $form_state->isValueEmpty([
    'options',
    'expose',
    'required',
  ])) {
    // Who cares what the value is if it's exposed and non-required.
    return;
  }
  $this->validateValidTime($form['value'], $form_state, $form_state->getValue([
    'options',
    'operator',
  ]), $form_state->getValue([
    'options',
    'value',
  ]));
}

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