Say i have a form with checkboxes or radio buttons in it, with no default values attached to them (meaning the blank form shows no pre-selected checkbox or radio).
I submit the form without checking any checkbox / radio, and say for any reason (for example, i left required fields empty...) the validation fails.
BUG : When the form is displayed back, all radios or checkboxes are checked
(of course for radio buttons, only one is selected - the last one-, but in the html they all are tagged 'checked="checked"')
The error probably lies in
function theme_radio - line 542 and
function theme_checkbox - line 726 :
the comparison between the form returned value (0 in my case) and the checkbox / radio value should use === instead of == :
(0 == 'any chain') is true.
The proposed patch corrects this, but I'm not at all familiar with the internal mechanics of the forms system, so I shouldn't know if this breaks anything alse...
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | empty_checkbox.patch | 1.21 KB | chx |
| #1 | form.inc_10.patch | 1.43 KB | yched |
| form.inc_9.patch | 1.39 KB | yched |
Comments
Comment #1
yched commentedOK - my patch is not the solution, it breaks the display of legitimate selected items.
This one _seems_ to make the job. Not sure it's the best way to do it
Once again i'm no expert regarding forms.inc. Please tell me if you think I should stick to submitting the issue rather than posting uncertified patches ?
Comment #2
chx commentedThis is a duplicate and now we have two patches for the same problem. I'll decide later today.
Comment #3
chx commentedComment #4
chx commentedUnable to reproduce in today's HEAD.
Comment #5
chx commentedReopening -- alphanumeric keys indeed produce this. Examining.
Comment #6
chx commentedSometimes the simplest solution is the best... I reviewed required checkboxes, too and changed the comment.
Comment #7
rkerr commentedPatch applies cleanly.
Any example of a form in default a HEAD install to test it on?
Comment #8
yched commentedCan't think of one right now, but the patch seems to do the trick for my own private forms...
+1 for a commit !
Comment #9
chx commentedI also tested this one throughly.
Comment #10
dries commentedCommitted to HEAD. Thanks.
Comment #11
(not verified) commented