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
Posted by Ryan Mauger (bittarman) on 2012-01-22T12:41:34.000+0000
Please use the FormErrors decorator for this, the Errors decorator is for element errors.
Posted by Peter Varga (pet.var) on 2012-01-22T12:44:57.000+0000
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"?
Posted by Peter Varga (pet.var) on 2012-01-22T12:47:44.000+0000
@Ryan Mauger: Thanks! I works even better.