2
votes

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 can'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'
        ));
    }
}
1

1 Answers

4
votes

Try this:

$this->setDecorators(array(
        'FormElements',
        'Form',
        array('FormErrors', array('placement' => 'prepend'))
    ));