I am facing an small issue regarding the Email Validation in my Zend Form.
$emailId = new Zend_Form_Element_Text('email');
$emailId->setLabel("Email Adresse")
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator(new Validator_EmailValidator())
->addValidator('NotEmpty')
->addValidator(
'NotEmpty',
TRUE,
array('messages' => array(
'isEmpty' => 'Please enter your email id.'
)
)
);
Currently it is showing the Email Error Messages as :
What I want is to set a single error message in the place of all these errors and that is as :
"'abcd@shdsjah' is not a valid Email Id."
Since I am new to the Zend Framework, I don't have much idea about it, although I tried some code but they are useless.
Please help.....
Thanks In Advance....
When I was new to zend-framework, I faced this problem and got solution by using setErrors() method as:
//this will immediately call the method markAsError() which will show the error always
$emailId->setErrors(array('Please enter a valid Email Id.'));
You can also try :
//this will clearErrorMessages() and after that set the error messages
$emailId->setErrorMessages(array("Please enter a valid Email Id."));
Write this code after your code.
I hope it will be helpful to you......
Pass true as second argument of addValidator (breakChainOnFailure). The validation will stop at the first failure and you will have only have one error message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With