News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHPMaster.com:
Setting Custom Error Messages for Zend_Form_Element
October 11, 2012 @ 08:58:37

On PHPMaster.com today there's a new post for all the Zend Framework (v1) users out there. In it, Aurelio De Rosa shows you how to set custom error messages for elements in a Zend_Form.

In this article I'll show the solution to a common problem which arises when a developer has to create a non-English website or application that is based on the Zend Framework. How do we mark a field of a Zend_Form which is a Zend_Form_Element as invalid, showing one or more custom error messages? The problem is mainly caused by the native counter-intuitive methods of the Zend_Form_Element class which I'll explain in more details.

He's included a basic example showing the creation of a form and the setup of a text element and some validators to match. He makes a controller and view to handle the output and submission then shows how to use "setErrors" (and "setErrorMessages") of the Zend_Form elements to setup that custom error. This only lets you set one message, though, regardless of the point of failure. To stop things when there's an error, you have to set the "breakChainOnFailure" parameter on the validator to false - then the message will make more sense.

0 comments voice your opinion now!
zendframework1 zendform custom error message element tutorial


blog comments powered by Disqus

Similar Posts

MaltBlue.com: \Zend\Db\Sql - Creating Joins and Unions with Ease

NetTuts.com: How to Use Selenium 2 With PHPUnit

IBM developerWorks: U2 PDO Driver Tutorial, Parts 1 & 2

PHP-Coding-Practices.com: How I Turned A Slow Array Sort Into A Quick One Using Quicksort Algorithm

Kevin Boyd: Retrofitted Login Throttling


Community Events





Don't see your event here?
Let us know!


install framework interview language community series symfony2 unittest api threedevsandamaybe introduction testing podcast laravel opinion list refactor release code developer

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework