addElement('Select', 'Category',array( 'label' => 'Category:', -6ren">
gpt4 book ai didi

php - 为什么会出现错误 "' 0' was not found in the haystack"?

转载 作者:可可西里 更新时间:2023-11-01 00:06:24 24 4
gpt4 key购买 nike

我有两个相关的组合框:

 $this->addElement('Select', 'Category',array(
'label' => 'Category:',
'AutoComplete'=> true,
'multiOptions' => array('0' => '-Category-',$a->GetCategories(),'2' => '-Add category-'),
'required' => true ));

$this->addElement('Select', 'SubCategory',array(
'label' => 'Sub Category:',
'AutoComplete'=> true,
//'multiOptions' => array('0' => '-Select Category-'),
'required' => true ));

我想显示第二个的内容,所以我在 Controller 中执行以下操作:

     if ($this->getRequest()->isPost()) {  //Le formulaire est-il posté ?
$formData = $this->getRequest()->getPost(); // récupère les infos des formulaires

if ($form->isValid($formData)) { //Si le formulaire passe la validation
$v = $form->getValues(); // On récupère les données du formulaire

$Category= $v['Category'];
$a=$form->getElement('Category')->getMultiOption('1');
$cat=$a[$Category];

$SubCategory =$v['SubCategory '];
$b=$form->getElement('SubCategory')->getMultiOption($SubCategory);

$this->view->test = $b ;


}

else {$form->populate($formData);}

/*Appel du web service d'authentification*/
}

当我点击提交按钮时,第二个组合框变为空,我得到:

'0' was not found in the haystack

谁能解释一下这是为什么?

最佳答案

错误消息来自 inArray 验证器。您可以通过设置选择元素的正确键来禁用它:

'registerInArrayValidator' => false

关于php - 为什么会出现错误 "' 0' was not found in the haystack"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10205624/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com