I'm using Zend Framework, and am curious about how people handle form submission. Right now, I'm using something like this:
public function editAction()
{
$form = my_form();
$this->view->form = $form;
if ($this->getRequest()->isPost() {
$params = $this->getRequest()->getPost();
if ($form->isValid($params) {
// process form
}
}
}
Having the page try to repost the form on refresh is just annoying, and frustrating for the user. I'd like to have all the form processing moved out of the 'edit' action, and into an 'update' action (a more RESTful approach). However, I haven't figured out a good way to take advantage of Zend_Form's built in validation decorators without using the above approach. Using the method above, error messages appear automatically if I $form->populate()
a form after calling $form->isValid()
.
Is there any good way to persist validation messages on a form across requests (using the decorators). If not, does anyone have a solid solution for storing form validation in the session?
Thanks.