Zend_Form - is there a way to repost into the form if it is invalid?
I am having trouble injecting form data b开发者_Python百科ack into the form so the form is not reset if it is invalid.
Any way to do that? Or, more importantly, best/most ideal way?
I have my form logic and checking, just need a little help in exactly where I should be focusing the above effort.
Thanks!
Yeah, the $form->isValid($_POST) call should handle it. For example:
$form = new Zend_Form();
$form->setAction('/submit');
$form->setMethod('post');
$form->addElement('text', 'first_name', array(
'label' => 'First Name:',
'required' => true));
if (!$form->isValid($_POST)) {
//handle errors
} else {
//success
}
精彩评论