In Zend Framework I'm using the standard FormErrors decorator to output form errors in one place, rather than outputting each error below its corresponding element. The decorator works the way I expect it to, except that I c开发者_运维问答an't figure out how to output the errors at the top of the form instead of at the bottom. Is there a way to do this?
My form class looks something like the following:
class Form_User extends Zend_Form {
init() {
$name = new Zend_Form_Element_Text('name');
$name->setRequired(true);
$name->removeDecorator('Errors');
$this->addElements(array($name));
$this->setDecorators(array(
'FormElements',
'Form',
'FormErrors'
));
}
}
Try this:
$this->setDecorators(array(
'FormElements',
'Form',
array('FormErrors', array('placement' => 'prepend'))
));
加载中,请稍侯......
精彩评论