You are here

function date_browser_validate in Date 5.2

Same name and namespace in other branches
  1. 5 date_views.inc \date_browser_validate()

Validate a view.

1 string reference to 'date_browser_validate'
_date_views_style_plugins in date/date_views.inc
Implementation of hook_views_style_plugins()

File

date/date_views.inc, line 546

Code

function date_browser_validate($type, $view, $form) {

  // list (and table) modes require there to be at least 1 field active.
  if (is_array($view['field'])) {
    $fields = array_filter(array_keys($view['field']), 'is_numeric');
  }
  if (!$fields) {
    form_error($form["{$type}-info"][$type . '_type'], t('The Date Browser requires at least one field.'));
  }

  // Make sure all arguments are set to 'Display all values'
  // and that a date argument has been provided.
  $found = FALSE;
  $options = array_keys(date_range_arg_options());
  foreach ($view['argument'] as $delta => $argument) {
    if (in_array($argument['options'], $options)) {
      $found = TRUE;
      if (is_numeric($delta) && $argument['argdefault'] != 2) {
        form_error($form['argument'][$delta]['argdefault'], t('Date Browser arguments must be set to \'Display All Values\'.'));
      }
    }
  }
  if (!$found) {
    form_error($form['argument'], t('A date argument must be added to a Date Browser view.'));
  }
}