Posted by Darren Oh on April 2, 2007 at 4:49pm
4 followers
Jump to:
| Project: | Drupal core |
| Version: | 6.x-dev |
| Component: | forms system |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
If no default value is given for the date field, it is supposed to default to today's date. However, expand_date() uses !isset() to determine whether a value has been given. Since the value is an empty string when not specified, this means the date field defaults to 1 January 1900. The attached patch fixes this by replacing !isset() with empty().
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| form.inc-date.patch | 735 bytes | Ignored: Check issue status. | None | None |
Comments
#1
If anyone would like to test this, I suggest trying the following code with and without the patch:
<?php$form['date'] = array(
'#type' => 'date'
);
$form = form_builder(NULL, $form);
$form = drupal_render($form);
echo $form;
?>
#2
Yup.
#3
Committed to 5.
#4
Committed to CVS HEAD. Thanks.
#5
The Drupal 4.7 Form API works differently, so it doesn't require fixing.
#6