pretty sure this should be doable; but if i add a "date" form field and then do a form_render nothing except the #title shows up (see jpg).
$form['nletter_signup']['email'] = array(
'#type' => 'textfield',
'#title' => 'Email Address',
);
$form['nletter_signup']['name'] = array(
'#type' => 'textfield',
'#title' => 'Name (optional)',
);
$form['nletter_signup']['birthday'] = array(
'#type' => 'date',
'#title' => 'Birthday (required)',
//'#date_format' => 'M d, y',
//'#date_timezone' => 'americas/toronto',
'#weight' => 3,
);
echo drupal_render_form('nletter_signup', $form);
ideally i would also like this to be a calendar popup; but only doc i see on how to do this states:
Add a type of #date_popup to any date, time, or datetime field that will use this popup. Set #date_format to the way the date should be presented to the user in the form. Set #default_value to be a date in the local timezone, and note the timezone name in #date_timezone.
and "Add a type of #date_popup to any date field" doesn't make any sense. Perhaps it should say "change the #type to 'date_popup' " although that doesn't work.
| Comment | File | Size | Author |
|---|---|---|---|
| date_form.jpg | 7.48 KB | liquidcms |
Comments
Comment #1
karens commentedYou are using #date, which is nothing the date field creates, it's a core form element that has its own behavior. As to how to use the Date API, there are documents in Advanced help and in the d.o. handbook that explain that. Your basic assumptions about how to create and render a form are also not right. You'll need to start with a basic form and create something that works, and then add a date field to it. I don't have time to provide tutorials on how to use FAPI, sorry!
This is not really a bug report, it is a support request.