我有一个表单元素 companyState 它是一个下拉框
$companyState = $this->createElement('select', 'companyState')
->addMultiOptions(
array (
'' => 'Select',
)
)
->setAttrib('id', 'companyState')
->setRequired(true)
->setAttribs(
array(
'title' => 'companyState',
'class' => 'st-select'
)
)
->removeDecorator('HtmlTag')
->removeDecorator('label');
并将表单元素作为 $this->addElements(array($companyState));
在控制器中,我从表中获取 companyState 名称并分配给如下表格
$stateListObject = ST_State_StateList::readStateListWithDetailsFromDatabase();
$stateListIterObject = new ST_State_StateListIter($stateListObject);
$stateNameArray = array();
for (; $stateListIterObject->valid(); $stateListIterObject->next()) {
$stateListObject = $stateListIterObject->current();
$stateNameArray[$stateListObject->id] = $stateListObject->state_name;
}
$companySettingsFormObject = App::getForm('Company', 'ST_CompanySettingsForm');
$obj = $companySettingsFormObject;
if (!($obj instanceof $companySettingsFormObject)) {
$companySettingsFormObject = App::getForm('Company', 'ST_CompanySettingsForm');
}
$companySettingsFormObject->getElement('companyState')->addMultiOptions($stateNameArray);
我收到一个致命错误:偶尔调用 zend 中非对象上的成员函数 addMultiOptions() ,但并非每次都如此。如果我对文件进行任何修改,例如添加/删除表单元素或从缓存中删除。发生此错误。请帮助如何跟踪问题并解决它