Checkboxes get populated on form validation

easp - February 18, 2009 - 17:03
Project:Webform
Version:6.x-2.7
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

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.

#1

easp - February 21, 2009 - 18:44
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

leafish_paul - March 10, 2009 - 18:58

#3

leafish_paul - March 11, 2009 - 11:00

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

methetweb - May 4, 2009 - 22:34

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

Zooney - June 16, 2009 - 20:30
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

quicksketch - June 16, 2009 - 21:03

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

easp - June 16, 2009 - 22:06

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

#8

quicksketch - June 17, 2009 - 00:13
Status:needs review» reviewed & tested by the community

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

#9

quicksketch - November 6, 2009 - 00:50
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

System Message - November 20, 2009 - 01:00
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.