php - Form Level Validation in Zend Framework -


I am using the Zend MVC framework with an ORM layer, and I'm trying to find out the best Throw the exceptions from the save () function of the object, and throw them in the Z Form as errors.

All exceptions coming out of the propell object are not known which field is due to error, so I'm thinking that instead of being forced to attach a particular form element to each error message, There is a way to add common error messages to the entire form. For example, I have a saved () call wrapped in an attempt / catch block, and I can add exceptions-> Mummies () to the errors of a form element:

 < Code> try {$ obj- & gt; Save (); Echo 'object successfully saved'; } Hold (exception $ E) {$ form-> Name- & gt; AddErrorMessage ($ e-> GetCode ()) "-". $ E- & gt; GetMessage ()); $ Form & gt; Name- & gt; MarkAsError (); $ Form & gt; Populate ($ formData); }  

But I want to be able to do something like this:

  try {$ obj-> save (); Echo 'object successfully saved'; } Hold (exception $ E) {$ form-> Junk error mail ($ e-> getCode ()) "-". $ E- & gt; GetMessage ()); $ Form & gt; MarkAsError (); $ Form & gt; Populate ($ formData); }  

I hope that makes sense, thanks for the help,

Dave

Do you think of errors from the database, or offer a validation level (which it has not been developed, and it is called save () Phase)?

If you want to use database errors, keep in mind that they will only return the first error (hence the user must submit four errors to enter the three errors). Also, to get field names from error messages, keep in mind that some keys are covered in many fields (" name and first_name should be unique").

For example, Symfony adds verification to the form layer. There, you can see all the fields at once, and can return many errors. But do you already do this, and only want to do it as a final investigation?


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -