keith Pope-4 wrote: > > 2009/3/26 fab2008 <[email protected]>: >> One more thing, about the forms, currently I use redirect after post >> pattern, so my actions that involve a form are like this code: >> >> public function someAction() { >> $form = $this->view->form = new someForm(); >> if ($this->getRequest()->isPost() && $form->isValid($_POST)) { >> // stuff with model and form data >> ... >> // redirect to another page >> $this->_helper->redirector(...); >> } >> } > > If your controllers use forms like this your Model depends on the > Controller, without the form your Model has no way of validating its > input unless you duplicate the validation/input filtering. By moving > Zend_Form within your Model you will get rid of this dependency, and > then you can unit test your models etc. > > You should read Matthews blog on this > > http://weierophinney.net/matthew/archives/200-Using-Zend_Form-in-Your-Models.html > > >
Awesome, this is what I am looking for... > Remember that Zend_Form has three aspects, display, validation and > filtering, therefore it is reasonable to only use the validation and > filtering parts in your Model, they then act like a domain level > service to your Models. > > I find it useful to remember that the MVC dependency rule goes: > > Interface (View) > Application (Controller) > Domain (Model, Services etc) > Infrastructure (DB,Session, libraries) > > Dependencies go in a downwards direction, so Application can depend on > Domain but Domain should not depend on Application. > Thanks for this explaination. I will be a best ZF programmer using your advices ;-) -- View this message in context: http://www.nabble.com/Models-and-input-validation-best-practices-tp22691571p22721458.html Sent from the Zend Framework mailing list archive at Nabble.com.
