Hi,

I have created my own module, in this i have input form on which, depends on the manufacturer selected from 1st drop down i have to fill up the model(2nd) drop down. I did it using AJAX, not an issue. But when i submit the form, i am getting "An illegal choice has been detected. Please contact the site administrator." error.

I had the same problem with Drupal5, but i used DENGEROUS SKIP CHECK and i was through it,
But for Drupal 6, i am not getting what to do.

Please help
Thanks in advance

Comments

j_ten_man’s picture

Are you creating the form yourself or are you using hook_form_alter() or what?

Easiest Solution: add the second select dropdown option when the form is first created, and then hide it. Make sure every possible option is there. From there, do what you've been doing.

Best Solution: load up the form that is cached during the AJAX call, change the select options, and recache the form. I have done this with AHAH before. Here is an example: http://www.nicklewis.org/node/967

kendre_paresh’s picture

yes, am creating the form myself.

When the form initially loaded, I had sql that fetch and fill the Manufacturer dropdown. and 2nd dropdown(model) is there but dont have options in it.
Now on select on 1st dropdown i called ajax to fill up the Model dropdown, till this its working fine. But when i submit the form am getting "An illegal choice has been detected".

Please suggest in this case what i have to do.

j_ten_man’s picture

Look at my previous response. You need to do one of the two options:

Easiest Solution: add the second select dropdown options when the form is first created, but hide it. Make sure every possible option is there. From there, do what you've been doing.

Best Solution: load up the form that is cached during the AJAX call, change the select options, and recache the form. I have done this with AHAH before. Here is an example: http://www.nicklewis.org/node/967

robbin.zhao’s picture

use
'#validated' => TRUE
for the select element. I have been looking for it for a long time and it works.
NOTE, when you added it, empty cache first.

bartezz’s picture

Not very safe but a fast and simple solution! Thanx for sharing...

________________
Live fast die young

ashhishhh’s picture

Thanks Robbin,
I checked many other places too. they were guiding to hack core drupal form for this.