我知道这个问题已经在这里回答了。但这对我不起作用。表单是使用 PluginLoader 生成的:
$formClass = Zend_Registry::get('formloader')->load('Payment');
$form = new $formClass(array('someval' => $my_arr));
付款.php:
class Form_Payment extends Zend_Form
{
protected $_someval = array();
public function init()
{
$this->setAction('payment/save');
//....
$this->addElement('multiCheckbox', 'store_id', array('label' => 'Someval:', 'required' => true, 'multiOptions' => $this->getSomeval()))
}
public function setSomeval($someval) {
$this->_someval = $someval;
}
public function getSomeval() {
return $this->_someval;
}
}
正如我所看到的,加载方法只返回类名,所以new $formClass();
是相等的new Form_Payment()
,但为什么这不接受参数?