-
Notifications
You must be signed in to change notification settings - Fork 2
/
datetimepicker.module
32 lines (27 loc) · 1.12 KB
/
datetimepicker.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
use Drupal\Component\Serialization\Json;
/**
* @file
* DateTimePicker module.
*/
function datetimepicker_element_date_callback(&$element, $form, $form_state) {
$element['date']['#attributes']['data-datetimepicker-widget'] = TRUE;
$element['date']['#attributes']['data-datetimepicker-settings'] = Json::encode($element['#datetimepicker_settings']);
}
function datetimepicker_element_time_callback(&$element, $form, $form_state) {
$settings = array(
'format' => $element['#date_date_format'],
'datepicker' => TRUE,
'timepicker' => FALSE,
'closeOnDateSelect' => TRUE,
) + $element['#datetimepicker_settings'];
$element['date']['#attributes']['data-datetimepicker-widget'] = TRUE;
$element['date']['#attributes']['data-datetimepicker-settings'] = Json::encode($settings);
$settings = array(
'format' => $element['#date_time_format'],
'datepicker' => FALSE,
'timepicker' => TRUE,
) + $element['#datetimepicker_settings'];
$element['time']['#attributes']['data-datetimepicker-widget'] = TRUE;
$element['time']['#attributes']['data-datetimepicker-settings'] = Json::encode($settings);
}