You are here

function date_all_day_date_combo_process_alter in Date 7.3

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

Implements hook_date_combo_process_alter().

File

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

Code

function date_all_day_date_combo_process_alter(&$element, &$form_state, $context) {

  // This hook lets us make changes to the date_combo element.
  $field = $context['field'];
  $instance = $context['instance'];

  // Add the all_day checkbox to the combo element.
  if (!empty($instance['widget']['settings']['display_all_day'])) {
    $parents = $element['#parents'];
    $first_parent = array_shift($parents);
    $all_day_id = $first_parent . '[' . implode('][', $parents) . '][all_day]';
    foreach (array(
      'value',
      'value2',
    ) as $key) {
      if (array_key_exists($key, $element)) {
        $element[$key]['#date_all_day_id'] = $all_day_id;
      }
    }
  }
  else {

    // @todo This seems like unused code? There is no $form here.
    $form['all_day']['#type'] = 'hidden';
    $form['all_day']['#value'] = 0;
  }
}