Download & Extend

Checkboxes get populated on form validation

Project:Webform
Version:6.x-2.7
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Checkboxes are selected upon validation on multi-page forms.

To reproduce the bug:

- Create a new webform
- Add a field, pagebreak, required field and a select component with multiple option checked.

Form should look like:

Field
Pagebreak
Required field
Select component with multiple option checked

- View form and click next to go to page 2
- Submit form without completing the required field and leaving the checkboxe(s) unchecked
- A validation error occurs as normal, but the checkboxe(s) are now checked

This bug does not happen on the first page of a multi-page form but does appear on any subsequent pages.

Comments

#1

Status:active» needs review

I determined that the function webform_expand_checkboxes was setting a checkbox as checked if the default value is set.

An unchecked checkbox has a value of 0 so the function determined the value was set.

I created a patch that sets the default value back to the value it was set instead of setting it to 1.

AttachmentSize
webform_checkbox_default_patch_376369.patch 714 bytes

#2

#3

Fixes the problem for me, thanks! The form I'm working on has several "Tick me for x..." type, single checkboxes as well as several drop-down select fields. Patch fixes the problem without affecting the other select components in the form.

#4

The fix works for me too, though I managed to cause a white screen error on setting it up.
Though my problem gets triggered by using the 'Additional Validation' feature.

#5

Version:6.x-2.6» 6.x-2.7

Will this patch end up being committed to the webform module?

This issue still exists in 6.x-2.7 so I've upgraded the version on this issue. It would be nice for this patch to be officially supported...

#6

The patch looks correct to me at first reading. It's almost been four months since the original patch was posted, has anyone had any trouble whatsoever after applying it? Changes to the select.inc file are always prone to error as handling checkboxes is difficult to get working correctly.

#7

I have been using this patch since I created it without problems.

#8

Status:needs review» reviewed & tested by the community

Awesome, I'll commit it next time I'm updating the 2.x branches.

#9

Status:reviewed & tested by the community» fixed

Finally committed for inclusion in the 2.9 version. I only committed to D6 versions as the FAPI changed significantly between D5 and D6, meaning patch would likely have adverse side-effects on D5.

#10

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.