0
創建元素就像在話題我嘗試創建一個表單時的元素在循環創建:Zend_Form的不能在循環
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);
}
}
但是,當我whant顯示在視圖的形式
<?php echo $this->filterform;?>
它的顯示屏只有數組aQuestionList和同樣的情況在最後一個元素是在第二循環 問候
如果您將$ aAnswerList設爲key =>值,則可以使用$ answer-> setMultiOptions($ aAnswerList);) – 2012-03-24 17:53:43