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

Issue Type: Bug Created: 2012-01-22T12:34:08.000+0000 Last Updated: 2012-01-22T12:47:44.000+0000 Status: Resolved Fix version(s): Reporter: Peter Varga (pet.var) Assignee: Ryan Mauger (bittarman) Tags: - Zend_Form

Related issues: Attachments:



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

This form:

<pre class="highlight">
class Login extends Zend_Form {
    public function init() {

        $this->addElement('text', 'login', array(
            'label'      => 'Name:',
            'required'   => true,
        $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:

<pre class="highlight">
if ($element instanceof Zend_Form)
    $errors = $element->getErrorMessages();
    $errors = $element->getMessages();


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.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.