I have two custom Drupal modules moduleA and moduleB. moduleA has all the functions for Ajax calls i.e. ajax_example_dependent_dropdown_callback and _ajax_example_get_second_dropdown_options.

I create a content type in moduleB called content_type_b. I am using Ajax calls in moduleB to populate drop down in content_type_b.

While creating content for content_type_b, I try to choose a value from the drop down. The first time, it works fine. The second time I get an error saying "An Illegal choice has been selected. Please contact the administrator". All these events happen before a node insert.

When I looked into the logs, the hook_node_validate of moduleA is getting called. The node insert must happen in moduleB. So node_validate of moduleB must be called. I think since the Ajax functions were present in moduleA, the node_validate of moduleA is being called.

Please advice how to proceed in this situation.


1 Answer 1


The issue was fixed by changing one of the fields in the Content Type to List(text) instead of node reference. After this the "Illegal choice error" disappeared.

Not the answer you're looking for? Browse other questions tagged or ask your own question.