You are here

function date_popup_element_info in Date 7.3

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

Implements hook_element_info().

File

date_popup/date_popup.module, line 173
A module to enable jQuery calendar and time entry popups.

Code

function date_popup_element_info() {
  $timepicker = date_popup_get_preferred_timepicker();

  // 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).
  //
  // #datepicker_options
  //   An associative array representing the jQuery datepicker options you want
  //   to set for this element. Use the jQuery datepicker option names as keys.
  //   Hard coded defaults are:
  //   - changeMonth => TRUE
  //   - changeYear => TRUE
  //   - autoPopUp => 'focus'
  //   - closeAtTop => FALSE
  //   - speed => 'immediate'
  $type['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'),
    '#datepicker_options' => array(),
    '#timepicker' => variable_get('date_popup_timepicker', $timepicker),
    '#date_increment' => 1,
    '#date_year_range' => '-3:+3',
    '#date_label_position' => 'above',
    '#process' => array(
      'date_popup_element_process',
    ),
    '#value_callback' => 'date_popup_element_value_callback',
    '#theme_wrappers' => array(
      'date_popup',
    ),
    '#attached' => array(
      'css' => array(
        drupal_get_path('module', 'date_popup') . '/themes/datepicker.1.7.css',
      ),
    ),
  );
  if (module_exists('ctools')) {
    $type['date_popup']['#pre_render'] = array(
      'ctools_dependent_pre_render',
    );
  }
  return $type;
}