1 date.elements.inc date_empty_end_date(&$element, &$form_state, &$input)

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

File

core/modules/date/date.elements.inc, line 1813
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 suppress validation errors and stop further
  // processing.
  $parents = $element['#parents'];
  $parent = array_pop($parents);
  if ($parent == 'value2') {
    $parent_values = backdrop_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);
    }
  }
}