You are here

function date_field_all_day_toggle_callback in Date 8

A callback for the time element to add an 'All day' checkbox to the form.

File

date_field/date_field.module, line 32

Code

function date_field_all_day_toggle_callback(&$element, &$form_state, $date) {
  if (!empty($element['#date_all_day_toggle'])) {
    $parents = $element['#parents'];
    array_pop($parents);
    $first_parent = array_shift($parents);
    $all_day_id = $first_parent . '[' . implode('][', $parents) . '][all_day]';
    $element['time']['#states'] = array(
      'visible' => array(
        'input[name="' . $all_day_id . '"]' => array(
          'checked' => FALSE,
        ),
      ),
    );
  }
}