1
的HTML我的複選框列表設置默認值是這樣的:Zend的形式 - 多選框
<dt id="list-label">
<label for="list" class="optional">
Choose which feeds to include in the mix
</label>
</dt>
<dd id="list-element">
<label for="list-1">
<input type="checkbox" name="list[]" id="list-1" value="1">Marko Polo
</label>
<br />
<label for="list-2">
<input type="checkbox" name="list[]" id="list-2" value="2">Jeano Polo
</label>
</dd>
我試圖與選擇=選擇那些從數據庫中的1值了預填充。我認爲以下將起作用:
$form->setDefaults(array('list-1'=>1,'list-2'=>1));
但它沒有。有沒有辦法做到這一點?
編輯
Here is my form class code:
$model = new Admin_Model_Db();
$model->setTableName('graduates');
$gradA = $model->getAllGraduates();
foreach ($gradA as $grad){
if (!empty($grad['twitter'])){
$twitter[$grad['id']] = $grad['firstname'] . ' ' . $grad['lastname'];
}
}
$list = $this->CreateElement('multicheckbox', 'list')
->setLabel('Choose which feeds to include in the mix')
->setRequired(false)
->setMultiOptions($twitter);
,你可以加入你的窗體類的代碼?我想我知道問題出在哪裏,但我需要確定 –