Why am I getting the error "0" not found in the haystack "?
I have two dependent fields:
$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 ));
I want to display the contents of the second, so in the controller I do the following:
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*/
}
When I click the submit button, the second summary becomes empty, and I get:
'0' not found in haystack
Can someone explain why this is?