Quantcast
Channel: PHPDeveloper.org
Viewing all articles
Browse latest Browse all 15

Jani Hartikainen's Blog: Validating Zend_Forms using model objects

$
0
0

Jani Hartikainen has posted a three-step process to his blog about handling the information submitted into a Zend_Form instance with a model.

Zend_Forms, models, validation and how they all work together is a tricky topic. There are many opinions and many ways to do it. This time I'll show you what I think could be the answer to validating forms without having to duplicate validation code both in a model class and in your form.

He creates a simple model interface (with get, set, isValid and getMessages methods) and a validator extended from Zend_Validate_Abstract to pass the information back into the model through an isValid method call. The validator is then added to each element you want to use it on in the addElement call on the Zend_Form object.


Viewing all articles
Browse latest Browse all 15

Trending Articles