开发者

Position Zend_Form errors above form using Zend_Form_Decorator_FormErrors

开发者 https://www.devze.com 2023-01-07 13:59 出处:网络
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 expec

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

精彩评论

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