1

how to implement a date field in my forms using the form API. I actually wanted a date popup field. I have use this code

$form['dob'] = array(
  '#type' => 'date_popup',
  '#title' => t('DOB'),
  '#date_format' => 'Y-m-d',
  '#date_year_range' => '-100:+0',
);

but it does not work..

1
  • --> How did u manage to solve it? Commented Sep 24, 2015 at 8:01

1 Answer 1

8

you would need to install the date module for date popup to work.

the following answer on stackoverflow has more details

How do I choose the "date_popup" widget for custom date field from code?

5
  • i have install the model and see this link but it still show me this error Undefined index: #id in theme_date_popup() (line 675 of all\modules\date\date_popup\date_popup.module). Commented Jan 18, 2013 at 21:26
  • are you using the same format as aove? and where are placing it? Commented Jan 19, 2013 at 4:52
  • yes I have using the same format as above . in my custom module Commented Jan 19, 2013 at 13:34
  • could you show be the full function that you have placed this in? Commented Jan 19, 2013 at 13:35
  • function _menu_example_menu_page {$form['dob'] = array( '#type' => 'date_popup', '#title' => t('DOB'), '#date_format' => 'Y-m-d', '#date_year_range' => '-100:+0', ); return $form; } do you have skype??? this my name (rasha.shareef) on skype could you add me :) Commented Jan 19, 2013 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.