Drupal Core 7.14 seems to have introduced/reintroduced an issue with radio form components that do not have a default and are not required/mandatory. In a webform, a select component that is not mandatory and has no default will cause the following error to occur on form submission: "An illegal choice has been detected. Please contact the site administrator." This essentially makes the component required/mandatory even when it should not. This was not the case in Drupal 7.12 and Webform 3.17.
To reproduce:
* Install fresh Drupal 7.14 and Webform 3.17
* Create a new Webform node
* Add a select component with everything as default, adding only several Options like 1|One
* Submit the form completely empty
* Error occurs
This issue is being discussed at http://drupal.org/node/811542 starting at post #177.
If this issue is only with Drupal Core and not Webform I apologize for the extra issue. That being said, if I create a new content type, and add a field of type List (Text) and only set Options and no default value or required, the error does not occur on form submission.
Comment | File | Size | Author |
---|---|---|---|
#8 | webform_empty_radios_grid.patch | 631 bytes | quicksketch |
#7 | webform_empty_radios_grid.patch | 2.03 KB | quicksketch |
#3 | i1565696-3.patch | 526 bytes | attiks |
#1 | webform_required_radios.patch | 815 bytes | quicksketch |
Comments
Comment #1
quicksketchThis isn't critical, though it is a serious inconvenience. It looks like a combination of the Drupal core upgrade and Webform's custom handling of validation code is responsible. I haven't checked all the side-effects, but at first glance Drupal core is now returning FALSE instead of NULL for empty radio buttons. This patch works-around the problem for Webform by checking for FALSE values in addition to the current NULL.
I haven't checked if this affects standard radio buttons outside Webform or not.
Comment #2
attiks CreditAttribution: attiks commentedCan someone test the patch in #811542-188: Regression: Required radios throw illegal choice error when none selected, it works for me in combination with webform (without altering webform)
Comment #3
attiks CreditAttribution: attiks commentedBy trying to fix this in core I discovered that components\select.inc was setting
$element['#default_value'] = FALSE;
, by removing this it appears to be working.Comment #4
quicksketchThanks attiks, I'll give that a shot.
Comment #5
mahtoranjeet CreditAttribution: mahtoranjeet commentedThanks for sharing patch it works for me.
Comment #6
quicksketchTested on both D6 and D7. I couldn't cause any problems with radios, checkboxes, or selects on either system, so looks good to me. I'll let testbot have a shot at it before a release.
Comment #7
quicksketchSimpletest turned up that Grid components has the same problem when left blank. This additional patch fixes the same problem with Grids.
Comment #8
quicksketchSorry debugging code in that last post. This is the patch to fix grids. Committed to both branches.
Comment #10
twooten CreditAttribution: twooten commentedI can confirm that updating to 7.x-3.18 fixed this issue for me. Thanks quicksketch.
Tim
Comment #11
Liam MorlandThe core issue is fixed here: #811542: Regression: Required radios throw illegal choice error when none selected
Comment #12
mmtt CreditAttribution: mmtt commentedThe both patches does not work for me. I'm using webform_select_options as Listbox, not as radio buttons. Every first entry after the very first "choose" entry generates "An illegal choice has been detected."