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.

Comments

Priority:Critical» Normal
Status:Active» Needs review
StatusFileSize
new815 bytes

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

Can 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)

StatusFileSize
new526 bytes

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

Thanks attiks, I'll give that a shot.

Thanks for sharing patch it works for me.

Status:Needs review» Fixed

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

StatusFileSize
new2.03 KB

Simpletest turned up that Grid components has the same problem when left blank. This additional patch fixes the same problem with Grids.

StatusFileSize
new631 bytes

Sorry debugging code in that last post. This is the patch to fix grids. Committed to both branches.

Status:Fixed» Closed (fixed)

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

I can confirm that updating to 7.x-3.18 fixed this issue for me. Thanks quicksketch.

Tim

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