You are here

function date_all_day_value in Date 8

Same name and namespace in other branches
  1. 7.3 date_all_day/date_all_day.module \date_all_day_value()
  2. 7.2 date_all_day/date_all_day.module \date_all_day_value()

A helper function to check if the all day flag is set on the parent of an element, and adjust the date_format accordingly so the missing time will not cause validation errors.

4 calls to date_all_day_value()
date_all_day_date_popup_pre_validate_alter in date_all_day/date_all_day.module
Implements hook_date_select_pre_validate_alter().
date_all_day_date_select_pre_validate_alter in date_all_day/date_all_day.module
Implements hook_date_select_pre_validate_alter().
hook_date_popup_pre_validate_alter in ./date.api.php
Alter the date_popup element before the rest of the validation is run.
hook_date_select_pre_validate_alter in ./date.api.php
Alter the date_select element before the rest of the validation is run.

File

date_all_day/date_all_day.module, line 284
Adds All Day functionality to the Date field.

Code

function date_all_day_value(&$element, $form_state) {
  if (!empty($element['#date_all_day_id'])) {
    $parents = $element['#parents'];
    array_pop($parents);
    $parent_element = drupal_array_get_nested_value($form_state['values'], $parents);
    if (!empty($parent_element) && !empty($parent_element['all_day'])) {
      $element['#date_date_format'] = date_part_format('date', $element['#date_date_format']);
      return $parent_element['all_day'];
    }
  }
  return FALSE;
}