You are here

function scheduler_admin_validate in Scheduler 6

Same name and namespace in other branches
  1. 7 scheduler.admin.inc \scheduler_admin_validate()

Validate the scheduler admin settings.

File

./scheduler.module, line 168

Code

function scheduler_admin_validate($form, &$form_state) {

  // Replace all contiguous whitespaces (including tabs and newlines) with a
  // single space.
  $form_state['values']['scheduler_date_format'] = trim(preg_replace('/\\s+/', ' ', $form_state['values']['scheduler_date_format']));
  if ($form_state['values']['scheduler_field_type'] == 'date_popup') {
    $format = $form_state['values']['scheduler_date_format'];
    $time_format = date_limit_format($format, array(
      'hour',
      'minute',
      'second',
    ));
    $acceptable = date_popup_time_formats();
    if (!in_array($time_format, $acceptable)) {
      form_set_error('scheduler_date_format', t('The Date Popup module only accepts the following formats: !formats', array(
        '!formats' => implode($acceptable, ', '),
      )));
    }
  }
}