Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By mtpultz on
I've placed a date field in my form
$fields['Preferred Date'] = array(
'#type' => 'date',
'#title' => t('Preferred Date of Program'),
//'#default_value' => ,
'#description' => t(''),
'#required' => TRUE
);
and it produces the three fields YY MM DD (though I liked to change their order to MM DD YY). How would I put a popup calendar beside this field and have the field change based on the calendar day chosen?
Comments
I believe you just set
I believe you just set '#type' => 'date_popup'
Sweet thanks, I'm looking at
Sweet thanks, I'm looking at the API now http://drupalcontrib.org/api/drupal/contributions--date--date_popup--dat... if I'm creating the date_popup how do I set the format using these functions? Just noticed you can get the time in there too but would like to change how it so the time is a drop down HH : MM instead of a textbox.
I'd also like it as select lists if possible instead of a text input, if that's possible.
Thanks again for the response, that's great
I'm not sure about time, as I
I'm not sure about time, as I haven't worked with that extensively. Here's an example call using the API though:
Thanks, that's great. I was
Thanks, that's great.
I was browsing through the Date/Calendar Docs and found that the date widget can be a select field. Is there another property to set that chooses what type of form input should be used.
Just incase it was this easy I tried using '#input' => 'select' and that didn't work. Seemed logical to try that though.
Thanks again
Never mind, I found out how
Never mind, I found out how to get selects from the docs http://drupal.org/node/292667. Thanks so much for the help. Appreciate it :)
Sorry, one more question.
Sorry, one more question. The last thing I need to do now that the field is in place is let the user know it is a date_popup field. Is there a property to show an icon to the right of the field like Wufoo forms does or how might you go about adding a clickable icon that would just open the date_popup for the associated field? Only thing I can see is add it to #suffix with some inlined script and css but that's pretty crude.
What about using the suffix
What about using the suffix to put in just the icon, and changing the CSS in your main file to have padding on the right-hand side that covers the area of the text field plus the icon?