You are here

function _webform_edit_time_validate in Webform 7.4

Implements hook_form_id_validate().

Validate start and end times.

1 string reference to '_webform_edit_time_validate'
_webform_edit_time in components/time.inc
Implements _webform_edit_component().

File

components/time.inc, line 125
Webform module time component.

Code

function _webform_edit_time_validate($form, &$form_state) {

  // Validate that the start and end times are valid. Don't validate the default
  // time because with token substitution, it might not be valid at component
  // definition time. The end time may be before the start time to facilitate
  // time ranges spanning midnight.
  foreach (array(
    'start_time',
    'end_time',
  ) as $field) {
    $time[$field] = FALSE;
    if (trim($form_state['values']['extra'][$field]) && ($time[$field] = strtotime('1-1-1970 UTC ' . $form_state['values']['extra'][$field])) === FALSE) {
      form_set_error("extra][{$field}", t("The @field isn't a valid time.", array(
        '@field' => $form['validation'][$field]['#title'],
      )));
    }
  }
}