Problem/Motivation
- AJAX form submissions seem to fail validation for other fields in the form. Examples:
- uploading files to filefields
- adding values to multiple-value fields
Sample steps to reproduce
- Create a new content type with a List (text) field, check/box radio button widget, allowed values Y and N, and make it required.
- Leave default value empty.
- Add a Filefield, allow these extensions: doc, docx, pdf, xls, xlsx, txt, and leave all other settings set to default (not required, public files, etc.).
- Allow these extensions: doc, docx, pdf, xls, xlsx, txt..
- Create content of the new type.
- Leave the List (text) field blank
- Upload an XLS file to the Filefield
Result:

Proposed resolution
- TBD
Remaining tasks
- TBD
User interface changes
- TBD
API changes
- TBD
Original report by gipsyx
All my file fields get an error when I try uploading files. I tried it on different content types, with different allowed extensions.
The error log says it's a form error, the message "Illegal choice in Type element."
The file fields where working fine until today, the only difference I could imagine was that I did some automatic updates, but I can't find a log of updated modules.
I don't know exactly what informations you need to fix this, please let me know if you need to know something else.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | Screenshot.png | 37.04 KB | peezy |
| Capture d’écran 2011-05-19 à 18.05.16.png | 43.34 KB | Anonymous (not verified) |
Comments
Comment #1
roam2345 commentedCan we see the file field settings you used?
Comment #2
Anonymous (not verified) commentedThis is the file field export from Features. Does that help?
Comment #3
sunIf this is really a bug in core, then we need clear steps to reproduce this bug in core (without contrib modules).
Comment #4
Wappie08 commentedHello Sun, I just reproduced this error, hopefully this is reproducable on a clean install (mine was not clean).
The bug is quite nifty:
- set a integer list field with some keys + values and set the field to required. Then either set the default value to N/A or do not touch the field at all.
- Then put an imagefield of filefield in the form and it gives an error when trying to upload an image/file before selecting an option on the required integer list.
I also had some form_alter functions which produced errors when uploading files, I figured out that putting all form_alter functions inside a if ($form_state['executed'] == FALSE) {} prevented all errors.
Greetings Wappie
Comment #5
dawehnerI tryed to reproduce the issue by
Then creating a node of this new type, touching nothing and upload a single image without changing the list-integer field.
And it worked fine without any kind of validation errors. The version used is the current git checkout of 7.x
Comment #6
xjmI was also unable to reproduce this bug using a current checkout of core and following exactly the steps provided in #4. It may already have been resolved by another issue if it was indeed a bug in 7.0. Otherwise, it may be related to contrib or custom code. Reopen if you can reproduce using 7.x-dev or 8.x-dev, and post exact steps to reproduce starting from installation. If the error only occurs after an upgrade from 6.x, then we'll want steps to reproduce from the D6 install if at all possible.
Comment #7
peezy commentedI was able to reproduced the illegal choice error on 7.10-dev and 7-9 by doing this:
The log reports the illegal choice in the List field.
Comment #8
xjm#7 doesn't sound to me to be related to the filefield? You're making the list field required and then submitting no value.
Comment #9
peezy commentedThanks for replying so quickly! I'll gladly post this elsewhere, if you wish.
So that you know, the error occurs only when I upload a file and only with the Radio Buttons/Checkbox widget (so, I'm not actually saving the node). When I change the text to a select list, I get the expected behavior (no error on upload). Also, the error renders in the Filefield area and not at the top of the page (please see attached screenshot).
Comment #10
xjmAhh. So it sounds like the AJAX submission is doing validation on the rest of the form, perhaps?
Comment #11
xjmThis is probably the same bug as:
#1120716: Clicking 'Add Another Item' causes 'An illegal choice has been detected error'
#1305694: Text field "Add another item" button validates unrelated fields, throws errors
Comment #11.0
xjmUpdated issue summary.
Comment #11.1
xjmUpdated issue summary.
Comment #11.2
xjmUpdated issue summary.
Comment #12
xjmComment #12.0
xjmUpdated issue summary.
Comment #13
xjmSee also #811542: Regression: Required radios throw illegal choice error when none selected, which we should take into consideration when testing this.
Comment #14
Anonymous (not verified) commentedyep, with the latest patch at #811542: Regression: Required radios throw illegal choice error when none selected i can't reproduce this any more. marking this as duplicate.
Comment #14.0
Anonymous (not verified) commentedUpdated issue summary.
Comment #15
elijah lynn