Removing the Zend_Form Default Method for Displaying Errors

Written by James Mansson on June 8, 2013 Categories: Zend Framework 1

The Zend_Form decorator system insists on displaying form errors as lists next to the field triggering the error. This is not always the behaviour that is desired. For instance, you may wish to display only the first error encountered, and show this above the form. In that case, you need to suppress the errors decorator for the fields where it applies. Fortunately, there is a simple method for doing this. Assuming that the form element is represent by the variable $element, we can make the following call:

$element->removeDecorator('Errors');

The element in question will now not display any associated errors next to it.

No Comments on Removing the Zend_Form Default Method for Displaying Errors

Leave a Reply

Your email address will not be published. Required fields are marked *