function NumericFilter::acceptExposedInput

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

Do some minor translation of the exposed input.

Parameters

array $input: The exposed data for this view.

Return value

bool TRUE if the input for this filter should be included in the view query. FALSE otherwise.

Overrides FilterPluginBase::acceptExposedInput

1 call to NumericFilter::acceptExposedInput()
Date::acceptExposedInput in core/modules/views/src/Plugin/views/filter/Date.php
Do some minor translation of the exposed input.
1 method overrides NumericFilter::acceptExposedInput()
Date::acceptExposedInput in core/modules/views/src/Plugin/views/filter/Date.php
Do some minor translation of the exposed input.

File

core/modules/views/src/Plugin/views/filter/NumericFilter.php, line 444

Class

NumericFilter
Simple filter to handle greater than/less than filters.

Namespace

Drupal\views\Plugin\views\filter

Code

public function acceptExposedInput($input) {
  if (empty($this->options['exposed'])) {
    return TRUE;
  }
  // Rewrite the input value so that it's in the correct format so that
  // the parent gets the right data.
  $key = $this->isAGroup() ? 'group_info' : 'expose';
  if (empty($this->options[$key]['identifier'])) {
    // Invalid identifier configuration. Value can't be resolved.
    return FALSE;
  }
  $value =& $input[$this->options[$key]['identifier']];
  if (!is_array($value)) {
    $value = [
      'value' => $value,
    ];
  }
  $rc = parent::acceptExposedInput($input);
  if (empty($this->options['expose']['required'])) {
    // We have to do some of our own checking for non-required filters.
    $info = $this->operators();
    if (!empty($info[$this->operator]['values'])) {
      switch ($info[$this->operator]['values']) {
        case 1:
          if ($value['value'] === '') {
            return FALSE;
          }
          break;

        case 2:
          if ($value['min'] === '' && $value['max'] === '') {
            return FALSE;
          }
          break;

      }
    }
  }
  return $rc;
}

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