我尝试做这种方式:的Zend - 填充组合框与数据库返回的数据
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;
}
我见过这种做它HERE,但它不起作用。回声工作正常,但组合框未填充。我的代码有什么问题吗?
谢谢! 索林
但我只想给ID添加到combobox – 2012-04-13 12:04:15
我这样做** $ set-> addMultiOption($ value-> cod_set_optional,$ value-> cod_set_optional); ** be因为我只需要代码...谢谢 – 2012-04-13 12:06:53