There is a bug either in profile.module (where it's called from) or form.inc with the "date" type form field. The date entered does not get saved.

To reproduce,

1. create a "date" field in user profile
2. set the date
3. save or just preview.

The date is going to be wrong. The reason is that all form field names for year, month, and day are the same:

<select name="edit[profile_bday]"  id="edit-profile_bday"><option ...  (for year)
...
<select name="edit[profile_bday]"  id="edit-profile_bday"><option ... (for month)
...
<select name="edit[profile_bday]"  id="edit-profile_bday"><option ... (for day)

Before the new Forms API they were:

<select name="edit[profile_date][year]" id="edit-profile_date-year"><option ...
...
<select name="edit[profile_date][month]" id="edit-profile_date-month"><option ...
...
 <select name="edit[profile_date][day]" id="edit-profile_date-day"><option ...

I couldn't figure this one out and write a patch...
Darius

CommentFileSizeAuthor
#5 expand_date.patch659 byteschx
#3 patch_191.14 KBdarius
#1 patch_18994 bytesdarius
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

darius’s picture

Title: New Forms API bug with "date" type form field (in profile.module) » Bug in forms.inc expand_date function (affects all '#type' => 'date' forms)
Component: profile.module » base system
Priority: Critical » Normal
Status: Active » Needs review
FileSize
994 bytes

OK, I figured this out myself, patch attached. The bug was in expand_date function in forms.inc.

Darius

chx’s picture

Status: Needs review » Needs work

'#name' => $element['#name']."[$type]" this makes no sense. Maybe you want $element['#tree'] TRUE? just a guess from the patch. If that works, then you can delete #parents and #tree from the [$type] array.

darius’s picture

Status: Needs work » Needs review
FileSize
1.14 KB

Yeah, my previous patch was a quick ugly hack (that worked). Thanks for the suggestion, the new patch attached.

Darius

Dries’s picture

Component: base system » forms system

chx?

chx’s picture

Assigned: Unassigned » chx
Priority: Normal » Minor
Status: Needs review » Reviewed & tested by the community
FileSize
659 bytes

In my test, the patch proved to be unnecessary. On the other hand, using #tree is cleaner, so let's use that.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)