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...

CommentFileSizeAuthor
#6 empty_checkbox.patch1.21 KBchx
#1 form.inc_10.patch1.43 KByched
form.inc_9.patch1.39 KByched

Comments

yched’s picture

StatusFileSize
new1.43 KB

OK - 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 ?

chx’s picture

Status: Active » Needs review

This is a duplicate and now we have two patches for the same problem. I'll decide later today.

chx’s picture

Assigned: Unassigned » chx
chx’s picture

Status: Needs review » Fixed

Unable to reproduce in today's HEAD.

chx’s picture

Status: Fixed » Needs review

Reopening -- alphanumeric keys indeed produce this. Examining.

chx’s picture

StatusFileSize
new1.21 KB

Sometimes the simplest solution is the best... I reviewed required checkboxes, too and changed the comment.

rkerr’s picture

Patch applies cleanly.

Any example of a form in default a HEAD install to test it on?

yched’s picture

Can't think of one right now, but the patch seems to do the trick for my own private forms...
+1 for a commit !

chx’s picture

Status: Needs review » Reviewed & tested by the community

I also tested this one throughly.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)