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

User login

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