I like to keep as much as possible in models
function editPersonAction()
{
$model = $this->getPersonModel();
if ($this->getRequest()->isPost() {
$data = $this->getRequest()->getPost();
if ($model->validateForm($data)) {
} else {
}
}
$this->view->form = $model->getForm();
}
So then in the model I would:
public function validateForm(array $data)
{
$form = $this->getForm();
if($form->isValid($data))
{
return true;
} else {
return false;
}
}
public function getForm($instance = 'default') {
if (!isset($this->_forms[$instance])) {
$this->_forms[$instance] = new Your_Form_Class();
$this->_forms[$instance]->populate($this->toArray());
}
return $this->_forms[$instance];
}
In addition, you can add these methods to an abstract model in which all your application models will be distributed, and then only overwrite them when you need to do something special.