You are here

public function DateRecurFilter::validateExposed in Recurring Dates Field 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/views/filter/DateRecurFilter.php \Drupal\date_recur\Plugin\views\filter\DateRecurFilter::validateExposed()
  2. 3.0.x src/Plugin/views/filter/DateRecurFilter.php \Drupal\date_recur\Plugin\views\filter\DateRecurFilter::validateExposed()
  3. 3.1.x src/Plugin/views/filter/DateRecurFilter.php \Drupal\date_recur\Plugin\views\filter\DateRecurFilter::validateExposed()

Validate the exposed handler form

Overrides HandlerBase::validateExposed

File

src/Plugin/views/filter/DateRecurFilter.php, line 312

Class

DateRecurFilter
Date range/occurrence filter.

Namespace

Drupal\date_recur\Plugin\views\filter

Code

public function validateExposed(&$form, FormStateInterface $form_state) : void {
  if (empty($this->options['exposed'])) {
    return;
  }
  if (empty($this->options['expose']['identifier'])) {
    return;
  }
  $identifier = $this->options['expose']['identifier'];
  if ($form_state
    ->isValueEmpty($identifier)) {
    return;
  }
  $input = $form_state
    ->getValue($identifier);

  // Check if element validator created errors.
  $element = $form[$identifier];
  if (!$form_state
    ->getError($element)) {
    $granularity = $this->options['value_granularity'];
    $timezone = new \DateTimeZone($element['#filter_plugin_user_timezone']);
    $this->smallestDate = DateRecurUtility::createSmallestDateFromInput($granularity, $input, $timezone);
    $this->largestDate = DateRecurUtility::createLargestDateFromInput($granularity, $input, $timezone);
  }
}