Kexiao Liao wrote:
> Where is the best place to do the input data(from POST variables) validation
> in the Zend Framework?
> 
> We can do the validation in following places:
> 1. Controller Class file
> 2. Use Defined Models Class file
> 
> Which one is the better choice?

Good question.  I've been creating a form processing utility class for
every form, then calling it from the action controller.  But
intuitively, I would have put it in the model.

The reason I didn't is that if I say:

  class book extends Zend_Db_Table_Abstract {}

  $table = new book();
  $book = $table->find(1);

  $errors = $table->validateInput($_POST); // or whatever...

This feels awkward and hard to understand.  Also, you tend to lose the
extra value that the validator object holds.

I suppose you could cobble together a composite model using a table
model together with validation, filtering, error message preparation,
etc (the stuff I now do in my form utility classes).

-- 
Drew Bertola

-------------------------------------------------
*   PHP/LAMP Consultant, ZCE-1000               *
*                                               *
*   Tel: 408-966-6671                           *
*                                               *
*   current resume:                             *
*   http://drewb.com/resume.pdf                 *
-------------------------------------------------

Reply via email to