I am unable to make Zend_Validate_EmailAddress show only 1 error message when the user enter invalid email address. The code is
$email = new Zend_Form_Element_Text('email');
$email->setLabel('Email: ')
->addFilter('StringTrim')
->addFilter('StripTags')
->addValidator('EmailAddress',true, array(... error msgs ...))
->addValidator(new Zend_Validate_Db_NoRecordExists(array( ... db + table + col details ... ),true, array(... error msgs ...)))
->setRequired(true);
$this->addElement($email);
And when user enter invalid email like user@email
(without the tld) it show multiple errors like
'email' is no valid hostname for email address 'user@email'
'email' does not match the expected structure for a DNS hostname
'email' appears to be a local network name but local network names are not allowed
I can't use addErrorMessage('...')
as I need to display different message for invalid email and for email already exists in database. So any idea how to make EmailAddress validation return only 1 error message.