我正在使用zend dojo表单,并希望从1911年到2011年填充组合选择选项。我在php手册中查找了这个函数的自动填充,但它在ZF dojo表单中不起作用。我得到这个错误信息
解析错误:语法错误,意想不到的'(',期待','或';'在第13行Signup.php
//options declaration
protected $_yearOptions = array_fill(
1911,101,'year');
//adding combo element
$this->addElement(
'ComboBox',
'comboyr',
array(
'label' =>'Birthyear',
'value' =>'',
'autocomplete' => false,
'multioptions' => $this->_yearOptions,
)
);
sign .php文件中的第13行必须是受保护的$_yearOptions属性。在类中设置属性时不能使用函数。你必须这样做:
protected $_yearOptions = array();
protected function _getYearOptions () {
if ( empty($this->_yearOptions) ) { $this->_yearOptions = array_fill(1911,101,'year'); }
return $this->_yearOptions;
}
然后在adelement中用这一行代替
'multioptions' => $this->_getYearOptions(),
也可以使用与array_fill不同的东西。我认为结果不是你想要的。