--- event.module.org 2008-08-21 14:27:23.000000000 -0400 +++ event.module 2008-08-21 14:58:47.000000000 -0400 @@ -1595,6 +1595,10 @@ function expand_event($element) { ); } + // Elements should be validated by default + if(!isset($element['#skip_validate'])) + $element['#skip_validate'] = false; + $element['#tree'] = TRUE; // Determine the order of day, month, year in the site's chosen date format. @@ -1696,6 +1700,10 @@ function _event_hour_to_ampm($hour) { * @param $form The form. */ function event_validate($form) { + + if($form['#skip_validate']) + return; + if (!checkdate($form['#value']['month'], $form['#value']['day'], $form['#value']['year'])) { form_error($form, t('The specified date is invalid.')); } @@ -2111,11 +2119,14 @@ function event_form_alter(&$form, $form_ '#weight' => -15, ); + // This needs to be validated only if has_end_date checked + // So we'll do that manually in the form validation function $form['event']['end_exploded'] = array( '#type' => 'event', '#title' => t('End date'), '#default_value' => isset($node->event['end_exploded']) ? $node->event['end_exploded'] : _event_user_time(), '#weight' => -13, + '#skip_validate' => true, ); if (variable_get('event_timezone_input', 'site') == 'input') { @@ -2171,6 +2182,11 @@ function event_form_alter(&$form, $form_ } } + + + + + /** * Helper function to add missing properties */ @@ -2751,6 +2767,21 @@ function event_implode_date($date) { return $date['year'] .'-'. $date['month'] .'-'. $date['day'] .' '. $date['hour'] .':'. $date['minute'] .':'. $date['second']; } + +/** + * Special validate handler for the node form + **/ +function event_form_validate($form, &$form_state) { + + if ($form_state['values']['event']['has_end_date']) { + $form['event']['end_exploded']['#skip_validate'] = false; + event_validate($form['event']['end_exploded']); + } + +} + + + /** * Special submit handler for the site timezone form. */