You are here

function date_popup_element_info in Date 7

Same name and namespace in other branches
  1. 7.3 date_popup/date_popup.module \date_popup_element_info()
  2. 7.2 date_popup/date_popup.module \date_popup_element_info()

Implement hook_element_info().

Set the #type to date_popup and fill the element #default_value with a date adjusted to the proper local timezone in datetime format (YYYY-MM-DD HH:MM:SS).

The element will create two textfields, one for the date and one for the time. The date textfield will include a jQuery popup calendar date picker, and the time textfield uses a jQuery timepicker.

NOTE - Converting a date stored in the database from UTC to the local zone and converting it back to UTC before storing it is not handled by this element and must be done in pre-form and post-form processing!!

#date_timezone The local timezone to be used to create this date.

#date_format Unlike earlier versions of this popup, most formats will work.

#date_increment Increment minutes and seconds by this amount, default is 1.

#date_year_range The number of years to go back and forward in a year selector, default is -3:+3 (3 back and 3 forward).

File

date_popup/date_popup.module, line 154
A module to enable jquery calendar and time entry popups. Requires the Date API.

Code

function date_popup_element_info() {
  return array(
    'date_popup' => array(
      '#input' => TRUE,
      '#tree' => TRUE,
      '#date_timezone' => date_default_timezone(),
      '#date_flexible' => 0,
      '#date_format' => variable_get('date_format_short', 'm/d/Y - H:i'),
      '#date_increment' => 1,
      '#date_year_range' => '-3:+3',
      '#process' => array(
        'date_popup_element_process',
      ),
      '#value_callback' => 'date_popup_element_value_callback',
      '#theme_wrappers' => array(
        'date_popup',
      ),
    ),
  );
}