我的问题是,以下 Zend Form 会引发错误。问题是“文件”元素和使用 setElementDecorators。
class Products_AddForm extends Zend_Form
{
function init() {
// other form elements...
$uploadElement = new Zend_Form_Element_File('Excel');
$uploadElement->setLabel('Excel');
$this->addElement($uploadElement);
$this->setElementDecorators(array(
'ViewHelper',
'Errors',
array(array('data' => 'HtmlTag'), array('tag' => 'td')),
array('Label', array('tag' => 'th')),
array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
));
}
}
这会引发错误。
(Warning: Exception caught by form: No file decorator found... unable to render file element Stack Trace: #0 )
$uploadElement->addDecorator('File');
在最后添加SetElementDecorators
将起作用,但这会给我两次文件元素!
有人可以帮忙吗?
TIA 马特