You are here

function date_empty_end_date in Date 8

Same name and namespace in other branches
  1. 7.3 date_elements.inc \date_empty_end_date()
  2. 7.2 date_elements.inc \date_empty_end_date()

Helper function to clear out end date when not being used.

2 calls to date_empty_end_date()
date_date_popup_pre_validate_alter in ./date_elements.inc
Implements hook_date_popup_pre_validate_alter().
date_date_select_pre_validate_alter in ./date_elements.inc
Implements hook_date_select_pre_validate_alter().

File

./date_elements.inc, line 463
Date forms and form themes and validation.

Code

function date_empty_end_date(&$element, &$form_state, &$input) {

  // If this is the end date and the option to show an end date has not been selected,
  // empty the end date to surpress validation errors and stop further processing.
  $parents = $element['#parents'];
  $parent = array_pop($parents);
  if ($parent == 'value2') {
    $parent_values = drupal_array_get_nested_value($form_state['values'], $parents);
    if (isset($parent_values['show_todate']) && $parent_values['show_todate'] != 1) {
      $input = array();
      form_set_value($element, NULL, $form_state);
    }
  }
}