I have set up a field collection with 2 fields - a node reference and a text field. I have then placed that node reference as a field on a content type and set it to be unlimited as far as the number of instances of that field one can place on that node. I can fill the content in and submit the node and that works, however, if I attempt to add another instance of the field within the field collections fieldset, I get an error that says "An illegal choice has been detected. Please contact the site administrator.".

I have found that if I add one instance of content in the field, then submit the node and go back and edit it to add additional instances of that field, the form works fine. It seems to be that adding multiple collections field instances containing a node reference produces errors on only node add form.

Is anybody else seeing this?

Erik.

Comments

bleen’s picture

I'm seeing this (suddenly) however I do not have any node ref fields in my collection. I have only three fields, all text.

Hmmmm

jschrab’s picture

Yep - I'm seeing this too. My case is a simple radio button set field.

bleen’s picture

I found the problem for me was that I had a required term reference field (as radio btns) farther down on the main form and that if I clicked add another item without first selecting one of those radio buttons then I got the "An illegal choice has been detected. Please contact the site administrator." message.

Once I made that field no longer required (which ultimately we wanted to do anyway) then my error went away. I didn't investigate what we would have done had we genuinely needed that field to be required.

The fundamental thing to keep in mind is that once the "add another item" button is pressed the entire form is submitted and validated (to some degree) so that message generally means there is some kind of validation error happening.

Hope this helps...

SocialNicheGuru’s picture

Title: Adding multiple field collection field instances containing a node reference produces errors on node add form » Adding multiple field collection field instances containing a node reference produces errors on node add form (required field)

adding to title because it seems that the required field and form validation is the issue

andiart’s picture

+1

drifter’s picture

This seems to be a core bug really. #limit_validation_errors is set correctly, which should prevent this behavior. It occurs with widgets that set #element_validate, and those seem to ignore #limit_validation_errors

See: #1488294: #element_validate functions are still called even when '#limit_validation_errors' => array()