Hi i been fooling around with some zend_forms
and i started to customize my error messages for my form-element validators.
i started out using the setRequired(true) to ensure that the value isnt
empty. but when i later wanted to change the error message i tried
instantiating a zend_validate_notempty(), change the error message IS_EMPTY
and addValidator() it to my element.
But it doesnt seem to validate it at all ? isnt it possible to add a
NotEmpty validator to an element ? or what am i doing wrong..
heres a test i wrote.
$form = new Zend_Form;
$form->setAction('/admin/auth/index/');
$form->setMethod('post');
$validatorNotEmpty = new Zend_Validate_NotEmpty();
$validatorNotEmpty->setMessages(
array(
Zend_Validate_NotEmpty::IS_EMPTY => 'Value is empty'
)
);
$myTest = $form->createElement('text', 'myTest');
$myTest->addValidator($validatorNotEmpty);
$form->addElement($myTest);
$form->addElement('submit', 'submit');
if ($this->getRequest()->isPost())
{
$form->isValid($_POST);
}
echo $form;
--
View this message in context:
http://www.nabble.com/Zend_Form_Element-validating-NotEmpty-not-working-tp17870897p17870897.html
Sent from the Zend Framework mailing list archive at Nabble.com.