Zend Framework form Invalidating the form
I have created a form with zend form. I process the data in one action and then redirect to the another action.
So in case of an error I redirect to the last form, if there was no error I redirect the user to another url.
So when isVa开发者_StackOverflow社区lid() fails I use the getMessages() (the getErrorMessages doesn't return anything) to get the messages, serialize it, place it in a session property and then redirect to the form page. My problem is now setting those error msg's in the form to let the user know there was a problem.
I have tried this
$form->setErrors(unserialize($this->_session->form_error_msgs));
But this doesn't do anything. What do I have to do to display the error msgs next to the fields??
you should add the error to the field, for example
$form->fieldname->addError('error message');
your code might not be working because you haven´t configured the form decorators...
精彩评论