1 |
85ad3d82
|
Assos Assos
|
Drupal date_popup.module README.txt
|
2 |
|
|
==============================================================================
|
3 |
|
|
|
4 |
|
|
Javascript popup calendar and timeentry using the
|
5 |
|
|
jquery UI calendar and a choice of jquery-timeentry libraries.
|
6 |
|
|
|
7 |
|
|
================================================================================
|
8 |
|
|
Datepicker
|
9 |
|
|
================================================================================
|
10 |
|
|
|
11 |
|
|
This code uses the jQuery UI datepicker that is included in core. Localization
|
12 |
|
|
of the interface is handled by core.
|
13 |
|
|
|
14 |
|
|
The popup will use the site default for the first day of the week.
|
15 |
|
|
|
16 |
|
|
================================================================================
|
17 |
|
|
Timepicker
|
18 |
|
|
================================================================================
|
19 |
|
|
|
20 |
|
|
There are three ways to let users select time in the Date Popup widgets.
|
21 |
|
|
You can choose between them by going to admin/config/date/date_popup.
|
22 |
|
|
|
23 |
|
|
The options are:
|
24 |
|
|
|
25 |
|
|
1) Manual time entry - a plain textfield where users can type in the time.
|
26 |
|
|
2) A 'default' jQuery timepicker, included in the code
|
27 |
|
|
(http://keith-wood.name/timeEntry.html).
|
28 |
|
|
3) The wvega timepicker (https://github.com/wvega/timepicker).
|
29 |
|
|
|
30 |
|
|
To install the alternate dropdown (wvega) timepicker:
|
31 |
|
|
|
32 |
|
|
Create a 'sites/all/libraries/wvega-timepicker' directory in your site
|
33 |
|
|
installation. Then visit https://github.com/wvega/timepicker/archives/master,
|
34 |
|
|
download the latest copy and unzip it. You will see files with names like
|
35 |
|
|
jquery.timepicker-1.1.2.js and jquery.timepicker-1.1.2.css. Rename them to
|
36 |
|
|
jquery.timepicker.js and jquery.timepicker.css and copy them into
|
37 |
|
|
'sites/all/libraries/wvega-timepicker'.
|
38 |
|
|
|
39 |
599a39cd
|
Assos Assos
|
The date_popup_timepicker module is also supported:
|
40 |
|
|
* https://www.drupal.org/project/date_popup_timepicker
|
41 |
|
|
|
42 |
|
|
|
43 |
85ad3d82
|
Assos Assos
|
================================================================================
|
44 |
|
|
Usage
|
45 |
|
|
================================================================================
|
46 |
|
|
|
47 |
|
|
To include a popup calendar in a form, use the type 'date_popup':
|
48 |
|
|
|
49 |
|
|
$form['date'] = array(
|
50 |
|
|
'#type' => 'date_popup':
|
51 |
|
|
'#title => t('My Date'),
|
52 |
|
|
....
|
53 |
|
|
);
|
54 |
|
|
|
55 |
|
|
Set the #type to date_popup and fill the element #default_value with
|
56 |
|
|
a date adjusted to the proper local timezone, or leave it blank.
|
57 |
|
|
|
58 |
|
|
The element will create two textfields, one for the date and one for the
|
59 |
|
|
time. The date textfield will include a jQuery popup calendar date picker,
|
60 |
|
|
and the time textfield uses a jQuery timepicker.
|
61 |
|
|
|
62 |
|
|
NOTE - Converting a date stored in the database from UTC to the local zone
|
63 |
|
|
and converting it back to UTC before storing it is not handled by this
|
64 |
|
|
element and must be done in pre-form and post-form processing!!
|
65 |
|
|
|
66 |
|
|
================================================================================
|
67 |
|
|
Customization
|
68 |
|
|
================================================================================
|
69 |
|
|
|
70 |
|
|
To change the default display and functionality of the calendar, set startup
|
71 |
|
|
parameters by adding selectors to your element. The configurable options
|
72 |
|
|
are:
|
73 |
|
|
|
74 |
|
|
#date_type
|
75 |
|
|
The type of date to convert the input value to, DATE_DATETIME, DATE_ISO, or
|
76 |
|
|
DATE_UNIX
|
77 |
|
|
|
78 |
|
|
#date_format
|
79 |
|
|
a standard PHP date format string that represents the way the month, day,
|
80 |
|
|
and year will be displayed in the textfield, like m/d/Y. Months and days
|
81 |
|
|
must be in the 'm' and 'd' formats that include the zero prefix, the year
|
82 |
|
|
must be in the 'Y' (four digit) format.
|
83 |
|
|
|
84 |
|
|
Any standard separator can be used, '/', '-', '.', or a space.
|
85 |
|
|
|
86 |
|
|
The m, d, and Y elements can be in any order and the order will be preserved.
|
87 |
|
|
|
88 |
|
|
The time selector will add AM/PM if 'a' is in the format string.
|
89 |
|
|
|
90 |
|
|
The default format uses the short site default format.
|
91 |
|
|
|
92 |
|
|
#date_year_range
|
93 |
|
|
the number of years to go backwards and forwards from current year
|
94 |
|
|
in year selector, in the format -{years back}:+{years forward},
|
95 |
|
|
like -3:+3
|
96 |
|
|
|
97 |
|
|
#date_increment
|
98 |
|
|
increment minutes and seconds by this amount, default is 1
|
99 |
|
|
|
100 |
|
|
================================================================================
|
101 |
|
|
Example:
|
102 |
|
|
================================================================================
|
103 |
|
|
|
104 |
|
|
$form['date'] = array(
|
105 |
|
|
'#type' => 'date_popup',
|
106 |
|
|
'#default_value' => '2007-01-01 10:30:00',
|
107 |
|
|
'#date_type' => DATE_DATETIME,
|
108 |
|
|
'#date_timezone' => date_default_timezone(),
|
109 |
|
|
'#date_format' => 'm-d-Y H:i',
|
110 |
|
|
'#date_increment' => 1,
|
111 |
|
|
'#date_year_range' => '-3:+3',
|
112 |
|
|
); |