You are here

function date_views_filter_handler::extra_options_validate in Date 7

Same name and namespace in other branches
  1. 8 date_views/includes/date_views_filter_handler.inc \date_views_filter_handler::extra_options_validate()
  2. 7.3 date_views/includes/date_views_filter_handler.inc \date_views_filter_handler::extra_options_validate()
  3. 7.2 date_views/includes/date_views_filter_handler.inc \date_views_filter_handler::extra_options_validate()

Validate the options form.

Overrides views_handler::extra_options_validate

File

date_views/includes/date_views_filter_handler.inc, line 153
A flexible, configurable date filter.

Class

date_views_filter_handler
This filter allows you to select a granularity of date parts to filter on, such as year, month, day, etc.

Code

function extra_options_validate($form, &$form_state) {
  $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 filter.'));
  }
  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'));
  }
}