douchuang4181 2015-07-20 11:14
浏览 27

Drupal Multiupload Filefield Widget与mutiselect ajax下拉列表冲突

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'];
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
    • ¥20 matlab yalmip kkt 双层优化问题