diff --git a/scheduler.module b/scheduler.module index 1bf6739..6ce60de 100644 --- a/scheduler.module +++ b/scheduler.module @@ -397,6 +397,7 @@ function scheduler_form_alter(&$form, $form_state) { '#required' => $publishing_required, '#default_value' => isset($defaults->publish_on) && $defaults->publish_on ? format_date($defaults->publish_on, 'custom', $internal_date_format) : '', '#description' => filter_xss($description_format . $description_blank), + '#value_callback' => 'scheduler_date_value_callback', ); } @@ -412,6 +413,7 @@ function scheduler_form_alter(&$form, $form_state) { '#required' => $unpublishing_required, '#default_value' => isset($defaults->unpublish_on) && $defaults->unpublish_on ? format_date($defaults->unpublish_on, 'custom', $internal_date_format) : '', '#description' => filter_xss($description_format . $description_blank), + '#value_callback' => 'scheduler_date_value_callback', ); } @@ -441,6 +443,26 @@ function scheduler_form_alter(&$form, $form_state) { } /** + * Callback function for the Scheduler date entry elements. + */ +function scheduler_date_value_callback(&$element, $input = FALSE, &$form_state) { + // When processing a delete operation the user should not be forced to enter a + // date. Hence set the scheduler date element's #required attribute to FALSE. + // Test the input operation against $form_state['values']['delete'] as this + // will match the value of the Delete button even if translated. + if (isset($form_state['input']['op']) && isset($form_state['values']['delete']) && $form_state['input']['op'] == $form_state['values']['delete']) { + $element['#required'] = FALSE; + } + // If using date popup then process the callback that would have been done had + // Scheduler not replaced this with its own one. If using plain text entry + // then no return value is needed. + if (_scheduler_use_date_popup()) { + $return = date_popup_element_value_callback($element, $input, $form_state); + return $return; + } +} + +/** * Displays a list of nodes that are scheduled for (un)publication. * * This will appear as a tab on the content admin page ('admin/content').