function Date::acceptExposedInput

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

Overrides NumericFilter::acceptExposedInput

File

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

Class

Date
Filter to handle dates stored as a timestamp.

Namespace

Drupal\views\Plugin\views\filter

Code

public function acceptExposedInput($input) {
    if (empty($this->options['exposed'])) {
        return TRUE;
    }
    // Store this because it will get overwritten.
    $type = NULL;
    if ($this->isAGroup()) {
        if (is_array($this->group_info)) {
            $type = $this->group_info['type'];
        }
    }
    else {
        $type = $this->value['type'];
    }
    $rc = parent::acceptExposedInput($input);
    // Restore what got overwritten by the parent.
    if (!is_null($type)) {
        $this->value['type'] = $type;
    }
    // Don't filter if value(s) are empty.
    $operators = $this->operators();
    if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id'])) {
        $operator = $input[$this->options['expose']['operator_id']];
    }
    else {
        $operator = $this->operator;
    }
    if ($operators[$operator]['values'] == 1) {
        // When the operator is either <, <=, =, !=, >=, > or regular_expression
        // the input contains only one value.
        if ($this->value['value'] == '') {
            return FALSE;
        }
    }
    elseif ($operators[$operator]['values'] == 2) {
        // When the operator is either between or not between the input contains
        // two values.
        if ($this->value['min'] == '' || $this->value['max'] == '') {
            return FALSE;
        }
    }
    return $rc;
}

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