I had several forms that would fail to submit with an "Illegal Choice" error when certain choices were selected within a form component type of "select". After some troubleshooting, I found that if an ampersand (&) is contained within the text of a selection choice, the webform will fail to submit with an "Illegal Choice" error if that particular choice is selected by a user.
So, as an example, if the selectable options for a "select" form component type are:
TUE: 10:00am (Ages 3 & 4)
TUE: 11:00am (Ages 4 - 6)
TUE: 12:30pm (Ages 4 - 6)
The user will receive an illegal choice error, and the form will not submit, if the first choice is among their selections when they complete the webform.
Obviously, it's easy enough to work around this problem by just using something different than a "&", but at a minimum I figured I should submit this as an issue so it's at least documented somewhere.
Comments
Comment #1
ohsweetie commentedthanks for posting this. we're having this error now. xo
Comment #2
quicksketchThanks, I've confirmed the bug and found an easy solution which I'll include in the 2.2 release. I'm currently on a plane, so I'll document the solution without a patch: Change line 421 of select.inc from
$rows = array_filter(explode("\n", _webform_filter_values(trim($text))));to
$rows = array_filter(explode("\n", _webform_filter_values(trim($text), NULL, NULL, FALSE)));Comment #3
quicksketchThis fix has been committed to both 5 and 6 branches.
Comment #4
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #5
aaronelborg commentedEdit: Sorted.
Nothing to see here............
Comment #6
scottrouse commentedI have Webform 5.x-2.10 installed on a Drupal 5.22 site. I'm still seeing this "Ampersand results in 'Illegal Choice'" issue even though it appears to have been patched back at 5.x-2.2. Other than "change the ampersand to the word 'and,'" does anyone have any suggestions?
Comment #7
quicksketchI suggest using key|value pairs for your select list values. This will avoid the problem of ampersands not working in your version of Webform.
Comment #8
quicksketchDrupal 5 is no longer actively supported, this will not be fixed in the 2.x version of Webform and it doesn't affect 3.x.