In my forms I don't want decorators to display my error messages in view, I want to display them by myself
in controller I have
public function registerAction()
{
$form = new Zend_Form;
$form->setAction('user/save')
->setMethod('post');
$user_name = $form->createElement('text','txt_username',array('class'=>'input'));
$user_name->addValidator('alnum')
->setRequired(true)
->setDecorators(array('ViewHelper'))
->addFilter('StringToLower');
$form->submit->setDecorators(array('ViewHelper'));
$this->view->form = $form;
$this->_form = $form;
$request = $this->getRequest();
if($request->isPost())
{
if($form->isValid($request->getPost()))
{
}
else
{
## here I want to display errors of form ##
print_r($form->user_name->getErrors()); //return empty array
print_r($form->getErrorMessages()); //return empty array
}
}
}
regards
Arslan Ali
没有评论:
发表评论