You are here

public function Time::validateOptionsForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Plugin/views/cache/Time.php \Drupal\views\Plugin\views\cache\Time::validateOptionsForm()

Validate the options form.

Overrides PluginBase::validateOptionsForm

File

core/modules/views/src/Plugin/views/cache/Time.php, line 140
Contains \Drupal\views\Plugin\views\cache\Time.

Class

Time
Simple caching of query results for Views displays.

Namespace

Drupal\views\Plugin\views\cache

Code

public function validateOptionsForm(&$form, FormStateInterface $form_state) {
  $custom_fields = array(
    'output_lifespan',
    'results_lifespan',
  );
  foreach ($custom_fields as $field) {
    $cache_options = $form_state
      ->getValue('cache_options');
    if ($cache_options[$field] == 'custom' && !is_numeric($cache_options[$field . '_custom'])) {
      $form_state
        ->setError($form[$field . '_custom'], $this
        ->t('Custom time values must be numeric.'));
    }
  }
}