Just like in topic I try to create a form when the elements create in loop:
foreach($aQuestionList as $aQuestionValue){
$aAnswerList = $oAnswerList->getListByQuestionId($aQuestionValue['newsletter_question_id']);
$oNote = new SilverCms_Core_Form_Element_Note('note',array('value'=>'<p>'.$aQuestionValue['newsletter_question_name'].'</p>'));
$this->addElement($oNote);
foreach($aAnswerList as $aAnswerValue){
$oCheckBox = new Zend_Form_Element_Checkbox('answer');
$oCheckBox->setLabel($aAnswerValue['newsletter_question_answer_name']);
$oCheckBox->isArray(true);
$oCheckBox->setCheckedValue($aAnswerValue['newsletter_question_answer_id']);
$this->addElement($oCheckBox);
}
}
But when I whant to display the form in view
<?php echo $this->filterform;?>
it’s display only last element in the array aQuestionList and the same situation is in second loop
Best Regards
You are using the same name (‘answer’) for each answer checkbox, so each will override the previous one. I think you actually want the Multicheckbox form element:
this will give you a checkbox and label for each option.