You are here

function date_api_argument_handler::options_validate in Date 6.2

Same name and namespace in other branches
  1. 6 date_api.views.inc \date_api_argument_handler::options_validate()

File

includes/date_api_argument_handler.inc, line 131
Views argument handler.

Class

date_api_argument_handler
Date API argument handler.

Code

function options_validate($form, &$form_state) {

  // It is very important to call the parent function here:
  parent::options_validate($form, $form_state);
  if ($form_state['values']['form_id'] == 'views_ui_config_item_form') {
    $check_fields = array_filter($form_state['values']['options']['date_fields']);
    if (empty($check_fields)) {
      form_error($form['date_fields'], t('You must select at least one date field for this argument.'));
    }
    if (!preg_match('/^(?:\\-[0-9]{1,4}|[0-9]{4}):(?:[\\+|\\-][0-9]{1,4}|[0-9]{4})$/', $form_state['values']['options']['year_range'])) {
      form_error($form['year_range'], t('Date year range must be in the format -9:+9, 2005:2010, -9:2010, or 2005:+9'));
    }
  }
}