Issues

ZF-12018: Zend_Form_Decorator_Errors unexpected behavior with Zend_Form (as element) attached to it.

Description

Hi!

I am new here, so let me know if this report is not written in the way it should.

This form:


class Login extends Zend_Form {
    public function init() {

        $this->addElement('text', 'login', array(
            'label'      => 'Name:',
            'required'   => true,
        ));
    
        $this->setDecorators(array(
            'FormElements',
            'Errors',
            'Form',
        ));
    
        $this->addErrorMessage('Invalid credentials provided');
        var_dump( $this->render() ); exit;
    }
}

should rendered error messages, but it did not. In Zend_Form_Decorator_Errors, there is calling of {{$element->getMessages()}} instead of {{$element->getErrorMessages()}}. I have (temporarily) fixed it by:


if ($element instanceof Zend_Form)
    $errors = $element->getErrorMessages();
else
    $errors = $element->getMessages();

Comments

Please use the FormErrors decorator for this, the Errors decorator is for element errors.

Ohh, I just find out it work, when I use {{$this->addError('Invalid credentials provided');}} instead of {{$this->addErrorMessage('Invalid credentials provided');}}.

Can be this issue somehow deleted or labed as "not relevant anymore"?

@Ryan Mauger: Thanks! I works even better.