i would like to add functionality from another module to my module

exbab - October 29, 2009 - 17:55

Specifically, I would like to add a date picker to my form that I've build in a module using FAPI. I see that the date module has a date picker in the sites/all/modules/date/date_popup.

How would I go about incorporating another module's form as part of my own module?

I have no clue where to begin on this so any help getting started would be appreciated.

Thanks!

i guess I partially answered

exbab - October 29, 2009 - 18:25

i guess I partially answered my own question by reading the README.txt file found with the date module. I copied the code found in the README.txt file into a my_module.install file for my_module. This let me create new form elements with the '#type' defined by the date module.

I'm still looking for documentation that says specifically what needs to go into an install file to allow this to happen.

Also, I'm still looking for documentation regarding other fields that may be defined by the form element. For example, I can get a form element on my page by entering:

$form['date'] = array( '#type' => 'date_popup', );

but I don't know what else can go into the array for this type ... I'll keep reading

For the sake of

exbab - October 29, 2009 - 19:31

For the sake of documentation:

Refer to: http://api.drupal.org/api/function/system_date_time_settings/6 for date time format strings.

I went with:

$form['date'] = array(
'#type' => 'date_popup',
'#date_format' => 'm/d/Y',
);

which displays a text field that is filled in by picking the date in a calendar. The value is returned in $form_state['values']['date']

Thanks, I'll review them!

exbab - October 29, 2009 - 21:43

Thanks, I'll review them!

 
 

Drupal is a registered trademark of Dries Buytaert.