How to create date popup in drupal custom module?

This is one of the most common feature that we need to implement in any project.

Here I am giving the step by step explanation with code.

1:- First download the date module from drupal.org.
2:-Enable the date & date popup module.
3:-Now go to your .module file (inside your custom module folder) then in hook_form function, and give #type=>date_popup.

Here is the code for the reference:-
        $format='d-m-Y';
        $form['date'] = array(
                '#type' => 'date_popup', //this is the main line of code that need to be add
                '#title' => t('Date'),
                '#date_format' => $format, //this date format can be changed as per the requirment
       );



 


No comments:

Post a Comment