Posted by David_Rothstein on April 21, 2011 at 3:53am
3 followers
| Project: | Webform |
| Version: | 7.x-3.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
One of the webform submission tests is failing, and it appears to be due to a real bug in D7 (does not occur in the 6.x-3.x code).
If you create a grid component with "0" as the key for one of the options, then when you view the form for the first time, the radio buttons corresponding to that option will be selected. As far as I can see, the desired behavior is that none of the radio buttons should ever be selected by default (to avoid bias).
The attached patch fixes this and makes the failing tests pass.
| Attachment | Size |
|---|---|
| webform-grid-default-value.patch | 2.34 KB |
Comments
#1
Note: I also think a similar bug exists if you create a regular set of radio buttons (using the "select options" component) and put "0" as one of the keys, but I haven't addressed that in the above patch. (That one does not seem to cause any failing tests.)
#2
Thanks David, I fixed half of this issue in #1151714: Grid component should use a #process function to expand itself, but I didn't think about the values being loaded from the database with a value of an empty string setting the default to 0. I've applied this patch which should accomplish the same functionality as your patch with the latest code. I removed the $element['#type'] == 'radios' part though because it felt a little too hacky, but since no value is going to be marked both #required and have a #value === FALSE, it should accomplish the same thing. Still passes tests for sure. Thanks again.
#3
Automatically closed -- issue fixed for 2 weeks with no activity.