當用戶輸入無效的電子郵件地址時,我無法使Zend_Validate_EmailAddress只顯示1個錯誤消息。該代碼是Zend EmailAddress驗證返回多個錯誤
$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);
當用戶輸入無效的電子郵件像[email protected]
(不TLD)顯示它像
'email' is no valid hostname for email address '[email protected]'
'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
多個錯誤,我不能使用addErrorMessage('...')
,因爲我需要顯示爲無效不同的消息電子郵件和電子郵件已存在於數據庫中。因此,任何想法如何使EmailAddress驗證返回只有1錯誤消息。
精確複製:http://stackoverflow.com/questions/1239719/in- a-zend-form-how-to-avoid-zend-validate-email-from-generating-multiple-errors – emaillenin