dimanche 19 avril 2015

How to populate data if zend form is not validated?

module.config contains form, that is injected into controller



'passwordForm' => function($sm){
$form = new \Application\Form\PasswordForm();

$form->setInputFilter(new \Application\Form\PasswordInputFilter());

return $form;
},


Controller:



if($this->getRequest()->isPost()){
$form->setData($this->getRequest()->getPost());

if($form->isValid()){
//ok
}
}
return array('form' => $form);


However, if the form is not validated, I see empty fields at form view <?=$this->formRow($this->form->get('passwordOld'));?>


How can I populate not validated values into the form? The key point is that the form is not binded to any object.


Aucun commentaire:

Enregistrer un commentaire