开发者

Position Zend_Form errors above form using Zend_Form_Decorator_FormErrors

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'))
    ));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜