繁体   English   中英

检测到非法选择。 请在使用 drupal 提交表单时联系网站管理员

[英]An illegal choice has been detected. Please contact the site administrator while submitting form using drupal 7

我正在尝试在 drupal 7 中提交表格,如果我选择国家字段下方显示的澳大利亚国家/地区选项,则我有针对国家/地区澳大利亚的州下拉字段。

我的状态列表:

public static $au_states = array(
"ACT" =>  "Australian Capital Territory",
"NSW" =>  "New South Wales",
"NT"  =>  "Northern Territory",
"QLD" =>  "Queensland",
"SA"  =>  "South Australia",
"TAS" =>  "Tasmania",
"VIC" =>  "Victoria",
"WA"  =>  "Western Australia",

 );

当我 select 下拉任何状态选项时,我检测到非法选择错误。 But important thing to notice If I select state: "NT" => "Northern Territory", in this case form is submitted successfully it does not show any error but except this state if I select any other states it display error. 我被困在哪里错了。? 您的帮助将不胜感激。

当您向表单添加新输入字段或添加/删除客户端上的某些字段选项时,通常会显示此错误消息(使用 javascript,在 Drupal 机制之外)。 在这种情况下,Drupal 将修改后的表单视为不安全(有点被陌生人入侵)并拒绝处理它。

据我了解,您有两个输入字段:国家的 select 输入和州的另一个输入。 这是你的情况吗? 如果是,您是否使用 javascript 操作第二个输入的选项(以显示所选国家/地区的状态)? Again if yes, you have to use Drupal Ajax API on the country input to manipulate options of the states input in server-side, to inform Drupal you have changed the options of the field deliberately and it is not by strangers!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM