You are here

function calendar_plugin_style::options_validate in Calendar 7.3

Validate the options form.

Overrides views_plugin_style::options_validate

File

includes/calendar_plugin_style.inc, line 161
Views style plugin for the Calendar module.

Class

calendar_plugin_style
Default style plugin to render an iCal feed.

Code

function options_validate(&$form, &$form_state) {
  $values = $form_state['values']['style_options'];
  if ($values['groupby_times'] == 'custom' && empty($values['groupby_times_custom'])) {
    form_set_error('style_options][groupby_times_custom', t('Custom groupby times cannot be empty.'));
  }
  if (!empty($values['theme_style']) && (empty($values['groupby_times']) || !in_array($values['groupby_times'], array(
    'hour',
    'half',
  )))) {
    form_set_error('style_options][theme_style', t('Overlapping items only work with hour or half hour groupby times.'));
  }
  if (!empty($values['theme_style']) && !empty($values['groupby_field'])) {
    form_set_error('style_options][theme_style', t('You cannot use overlapping items and also try to group by a field value.'));
  }
  if ($values['groupby_times'] != 'custom') {
    form_set_value($form['groupby_times_custom'], NULL, $form_state);
  }
}