Hi I am trying to change a date field on a form so that only the month and year are options for the user.

As of now, my code looks like this:

$format = 'm-Y';
$date = '01-2010';
$form['wpDate'] = array(
'#type' => 'date_select',
'#title' => t('Date of Latest Revision'),
'#required' => TRUE,
'#weight' => 8,
'#default_value' => $date,
'#date_format' => $format,
);

This is based on the content of this website.... http://drupal.org/node/292667                                                    

however, this field just won't appear on my form. every time i change the #type from "date" to "date_select" the field vanishes.

Any help?

Comments

pbarnett’s picture                                        

                                       

Do you have the Date API module installed and enabled?

jrs69’s picture                                            

                                           

Thanks, the Date API module was exactly what I was missing.


                                           


                                           


                                           


                                           


                                           


                                           

来自  https://www.drupal.org/forum/support/module-development-and-code-questions/2010-09-13/date_select