Drupal Date Popup from Form API


/ Published in: PHP
Save to your folder(s)

I can never remember how to trigger the Date Popup widget when writing a $form in Drupal so I've pulled out the instructions below.

This requires that the date_api, date_timezone and date_popup modules are all enabled.


Copy this code and paste it in your HTML
  1. /*
  2.  * Set the #type to date_popup and fill the element #default_value with a date adjusted to
  3.  * the proper local timezone in datetime format (YYYY-MM-DD HH:MM:SS).
  4.  *
  5.  * #date_timezone
  6.  * The local timezone to be used to create this date.
  7.  *
  8.  * #date_format
  9.  * Unlike earlier versions of this popup, most formats will work.
  10.  *
  11.  * #date_increment
  12.  * Increment minutes and seconds by this amount, default is 1.
  13.  *
  14.  * #date_year_range
  15.  * The number of years to go back and forward in a year selector,
  16.  * default is -3:+3 (3 back and 3 forward).
  17.  *
  18.  */

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.