I have just downloaded today the CVS version of Category module and the latest version of Drupal.

In trying to replicate the Container and Category setup of the Category Module demo site, I received the following error when trying to add a category to a container:

An illegal choice has been detected. Please contact the site administrator.

I had read previously that this bug had been reported and apaprently fixed?


nicholasThompson’s picture

I've found that a common cause of this is if a form posts to another form but doesn't clear its $edit details from the $_POST. Drupal then thinks you're editing the next form rather than moving onto a new one and sometimes cant fill in fields that dont exist.

This was a problem we had to get around for the Quiz module.

TheWhippinpost’s picture

I came across this problem when working with 2 browsers - IE and FF. I assumed it was a permissions or session-type issue.

liquidcms’s picture

i am just upgrading a site from 4.6 to 4.7 and i noticed this same error caused when i added the poormanscron and privatemsg modules into my setup.

Clearing the sessions table (and i also cleared the cache) seems to have fixed it.


karunadev’s picture

I receive this error, and a message in the log "Illegal choice in Parent element." when using the Internationalization module to add a translation of a category (book content as category).

raphael_kariuki’s picture

Hi, I saw an answer that works on this link


nightlife2008’s picture

Hi people,

I've been dealing with the same error on some client's websites. I've been able so solve it and wrote my solution down at: http://www.halecommunications.be/blog/?p=88

Hope I can be of any assistance!



jcmartinez’s picture

Title:An illegal choice has been detected. Please contact the site administrator.» Try this before doing anything complicated

Before doing anything complicated, double check that there is an input format selected. I changed my default input format and for some reason no input format was selected by default in the form for entering new content. Since input format is probably collapsed, you may not see it.

I edited the content type and selected a couple of formats and the issue got fixed. Now when I create new content, there is one format selected by default and the submit of the page works great.

Hope it can save you some time.

jcmartinez’s picture

Title:Try this before doing anything complicated» An illegal choice has been detected. Please contact the site administrator.

Sorry I changed the title of the issue unintentionally. Here is back.

scottybrookie’s picture

I got this message when trying to select certain departments in a list of checkboxes. Some departments worked, some generated the "illegal choice" message. The problem turned out to be that some departments' names had ampersands in them and others didn't. When I changed the ampersands to "and" that fixed it.

Before (generates error):
Art Department
Digital Arts & New Media

After (works):
Art Department
Digital Arts and New Media

zincdesign’s picture

Solved my issue - thanks scottyfb !

earwax’s picture

My problem was that I was using conditional fields module. If you hide radio options with the conditional fields module and they are required, then they still have to be selected, even though the radio options are hidden.

pratip.ghosh’s picture

I know it might be a bit late to discuss this query again, but i am having the same problem. I'll give you my scenario, any help is really appreciated.

I have a dropdown created along with some other form elements using Drupal 7 form API as follows :

$form['module_id'] = array(
        '#type' => 'select',
        '#attributes' => array('style' => array('width:300px;'), 'onchange' => 'date_range_toggle(this.value)'),
        '#empty_option' => t('-- Select Module  --'),
        '#options' => $modules,   
        '#required' => TRUE,
        '#id' => 'module_id',
        '#default_value' => $sel_mod,

The javascript function "date_range_toggle" called from these dropdowns has the following content :

              type: "GET",
              url: "<?php echo base_path(); ?>" + "admin/structure/product_manager/populate_fields/"+split_arr[0]+"/"+parent.jQuery('#taxonomy_term_data_tid').val(),
              success: function(content)

As noted this is an ajax function calling a page "populate_fields". Now i show you the content written in the .module file :

In menu hook :

$items['admin/structure/product_manager/populate_fields'] = array(
            'title' => t('Populate '),
            'page callback' => 'drupal_get_form',  
            'page arguments' => array('populate_fields'),
            'access arguments' => array('product_module_manager'),
            'type' => MENU_CALLBACK,
            'file' => 'product_manager.inc',

In theme hook :

'populate_fields' => array(
        'render element' => 'form',
        'arguments' => array('form' => NULL), 
        'template' => 'templates/populate_fields', 

... And finally the .inc file :

function populate_fields($form, &$form_state, $module_id, $access_level_id=NULL)
      ... some code
      ... some code

      $html_str = '';         

        $form['condition_field_'.$i] = array(
            '#type' => 'select',
            '#attributes' => array('class' => array('condition_drpdwn'), 'onchange' => 'javascript:populate_values('.$module_id.',this.value,'.$i.')'),
            '#options' => $moduleFieldList,   
            /*'#id' => 'condition_field_'.$i,*/
            '#name' => 'condition_field_'.$i,
            '#default_value' => '',

        $html_str .= drupal_render($form['condition_field_'.$i]);
  echo $html_str;exit;

Now, when the ajax is fired, it works perfectly, but when I submit the form, it shows the error : an illegal choice has been detected. please contact the site administrator

Please help someone...

nodeAche’s picture

I had that message showing on my form while trying to upload an image.
I got my issue resolved by giving a default value to my forms required fields.

phponwebsites’s picture

I'm also getting this error when trying to upload images using media browser on particular datatypes.