I have created a multiupload field in my node using Multiupload Filefield Widget. I am using the code below to alter the default node form.

There is an ajax based dependent dropdown field in the form i.e city dependent on country.When I select a single country the form work fine. But when I select multiple values form the country list I get the follwing error:

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

I get this particular error when there is the multiupload form element present. When I remove the element from $form its works fine with multiple selected values.

Please help me out to solve this problem.Thanks in advance!

function mymodule_form_alter(&$form, &$form_state, $form_id) {
    switch ($form_id) {
        case 'mynode_node_form':
            $country_list = load_countries();
            $selected_country = (isset($form_state['values']['country'])) ? $form_state['values']['country'] : key($country_list); 

            $form['countries'] = array(
                '#type' => 'select',
                '#title' => t('Select Your Country'),
                '#options' => $country_list,
                '#default_value' => $selected_country ,
                '#ajax' => array(
                    'callback' => 'city_dropdown_callback',
                    'wrapper' => 'city_wrapper',
                '#multiple' => TRUE,
                '#required' => TRUE,

            $cities_list = load_cities($selected_country);
            $selected_cities = (isset($form_state['values']['cities'])) ? $form_state['values']['cities'] : key($cities_list);
            $form['cities'] = array(
                '#type' => 'select',
                '#title' => t('Select Your City'),
                '#prefix' => '<div id="city_wrapper">',
                '#suffix' => '</div>',
                '#options' => $cities_list,
                '#default_value' => $selected_cities,
                '#multiple' => TRUE,
                '#required' => TRUE,

function city_dropdown_callback($form,$form_state){
    return $form['cities'];

Solved by issues by updating jquery.form.js to version 3.51.

Found the solution at : https://www.drupal.org/node/153774#comment-9202403

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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