我尝试这样做:
public function init()
{
/* Form Elements & Other Definitions Here ... */
$sets_table = new Optionals_Model_DbTable_Sets();
$set = new Zend_Form_Element_Select('set');
$set ->setLabel('Alegeti setul de optionale:');
foreach ($sets_table->getSets() as $value) {
echo $value->cod_set_optional;
$set->addMultiOption($value->cod_set_optional);
}
$submit = new Zend_Form_Element_Submit('Continua');
$this->addElements ( array (
$set,
$submit
) );
}
DbTable 中的 getSets() 如下所示:
public function getSets()
{
$select = $this->select();
$rows = $this->fetchAll($select);
if (!$rows) {
throw new Exception("Could not find!");
}
return $rows;
}
我在这里看到过这种做法,但它不起作用。回声工作正常,但未填充组合框。我的代码有问题还是什么?
谢谢!索林