In my model
$form = new \Zend_Form();
$form->addElement('text', 'name', array(
'validators' => array(
array('NotEmpty', true),
array("stringLength", true, array(1,40))
),
'required' => true,
'label' => "Name",
));
return $form;
In my controller, called above model function
if($form->isValid($_POST)) {
....
} else {
$form = Product::getForm();
print_r($form->getErrors());
print_r($form->getErrorMessages());
print_r($form->getMessages());
}
I am using Zend Framework.
Here in name field in form, string with more than 40 chars needs to display error messages.
I tried with get error with getErrors()
and getErrorMessages()
. But none of these function give me error.
It returns an empty array on printing the these functions.
Please help me to solve this problem...