function fullcalendar_create_date_combo_process_alter in FullCalendar Create 7
Implements hook_date_combo_process_alter().
Populates the date fields. FullCalendar passes dates as ISO8601 in UTC.
File
- ./
fullcalendar_create.module, line 77 - Provides click-to-create functionality for FullCalendar.
Code
function fullcalendar_create_date_combo_process_alter(&$element, &$form_state, $context) {
if (empty($form_state['fullcalendar_create_date_field']) || !in_array($element['#field_name'], $form_state['fullcalendar_create_date_field'])) {
return;
}
// Check for an end date first.
if (isset($_POST['fullcalendar_create_end_date'])) {
$end_date = new DateObject(check_plain($_POST['fullcalendar_create_end_date']), 'UTC');
$end_date = $end_date
->format(DATE_FORMAT_DATETIME);
}
// Check for a start date.
if (isset($_POST['fullcalendar_create_start_date'])) {
$start_date = new DateObject(check_plain($_POST['fullcalendar_create_start_date']), 'UTC');
$start_date = $start_date
->format(DATE_FORMAT_DATETIME);
// If there was no end date, use the start date.
if (!isset($end_date)) {
$end_date = $start_date;
}
// Set in all four default value locations.
$element['#default_value']['value'] = $start_date;
$element['#default_value']['value2'] = $end_date;
$element['value']['#default_value'] = $start_date;
$element['value2']['#default_value'] = $end_date;
}
}