Hi,
Was working on custom validation messages for a form I am working up and ran into a little snag.
My custom 'isEmpty' message works perfectly. My custom email address messages fall apart.
Entering in 'ff@ff' throws the following:
Code:
This does not appear to be a valid email address (GOOD My custom Message)
'ff' does not match the expected structure for a DNS hostname -(Default)
'ff' appears to be a local network name but local network names are not allowed -(Default)
Ideally what I would like is for it to just throw the first custom message and skip the others but the way my code is I expected the first message all 3 times:
PHP Code:
$email = new Zend_Form_Element_Text('email');
$email->setLabel('Your Email Address:')
->addFilter('StringToLower')
->setRequired(true)
->addValidator('NotEmpty', true, array(
'messages' => array(
'isEmpty' => 'Required - Please fill in your Email Address')))
->addValidator('EmailAddress', true, array(
'messages' => array(
'emailAddressInvalid' => 'This does not appear to be a valid email address',
'emailAddressInvalidHostname' => 'This does not appear to be a valid email address',
'emailAddressInvalidMxRecord' => 'This does not appear to be a valid email address',
'emailAddressDotAtom' => 'This does not appear to be a valid email address',
'emailAddressQuotedString' => 'This does not appear to be a valid email address',
'emailAddressInvalidLocalPart' => 'This does not appear to be a valid email address',
)));
Any thoughts on what I might be doing wrong? How to fix? How to get it to spit out just the one error message?
Thanks!