The date type of forms is not working. Looking at the generated HTML, all fields of get the same name attribute in the select tags for days, months and years.

For example:

<select name="edit[profile_birth]"  id="edit-profile_birth"><option value="1">Jan</option> [...]
<select name="edit[profile_birth]"  id="edit-profile_birth"><option value="1">1</option> [...]
<select name="edit[profile_birth]"  id="edit-profile_birth"><option value="1900"> [...]

Looking at the source code, function expand_date does not define #name fields. So function _form_builder assigns a name in the recurse for month, year and day. This is done using:
$form['#name'] = 'edit[' . implode('][', $form['#parents']) . ']';.
This bases the name only upon the parent, and nowhere uses an child-specific name. Hence this problem.

I am not sure whether the fix would be to change expand_date to add #name fields (nasty), to change expand_date to generate more sensible #name fields, or whether the root cause is somewhere else again.

One way to reproduce this bug is to enable the profile module, define a date field (for example birthday) and try to fill it in. You will see a wrong date is entered.

  Frodo

CommentFileSizeAuthor
#3 form_date_1.patch741 byteschx
#2 form_date_0.patch1.62 KBchx

Comments

fax8’s picture

I confirm this bug...

chx’s picture

Component: base system » forms system
Assigned: Unassigned » chx
Status: Active » Reviewed & tested by the community
StatusFileSize
new1.62 KB

And I fixed this bug. Very easy.

Just by looking into this, I discovered two profile bugs, will file tickets.

chx’s picture

StatusFileSize
new741 bytes

A few notices are removed in that patch which are not relevant to this issue.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)