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.

Members fund testing for the Drupal project. Drupal Association Learn more


quicksketch’s picture

Priority: Critical » Normal
Status: Active » Needs review
815 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.

attiks’s picture

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)

attiks’s picture

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

quicksketch’s picture

Thanks attiks, I'll give that a shot.

mahtoranjeet’s picture

Thanks for sharing patch it works for me.

quicksketch’s picture

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.

quicksketch’s picture

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

quicksketch’s picture

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.

twooten’s picture

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


Liam Morland’s picture

mmtt’s picture

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