How to use datepicker pop up in a form field in a custom module?

Ever needed to use datepicker pop up in a custom module? That would be the most usable way to allow users to choose a date.

Here is the code to be used in the form function:

<?php
$format
= 'd-m-y';
 
$form['date_from'] = array(
   
'#title' => t('Date From'),
   
'#type' => 'date_popup',
   
'#date_format' => $format,
   
'#description' => t('Please select a date'),
  );
?>

Tags: 
Drupal 6, Drupal Quick Tips

Recent Comments

Forward by Dries Buytaert, Founder and Project Lead, Drupal; CTO Acquia.

Order now from:

Managing Expectations Podcast with DrupalEasy

Author Interview http://tinyurl.com/8a8nxno

We provide the most Shiny Drupal Bits & Pixels

Since Drupal 4.x