class Form_Accounts_Add extends Zend_Form {
public function init($options=array()) {
$first_name = new Zend_Form_Element_Text('first_name');
$last_name = new Zend_Form_Element_Text('last_name');
$email = new Zend_Form_Element_Text('email');
$password = new Zend_Form_Element_Text('encrypted_password');
$first_name->setRequired(false);
$last_name->setRequired(false);
$email->setRequired(true)->addFilter('StringToLower')->addValidator('NotEmpty', true)->addValidator('EmailAddress');
$password->setRequired(true);
$this->addElements(array($first_name, $last_name, $email, $password));
}
}
如果电子邮件无效,我会收到错误信息:$form->getErrors('email')返回的是emailAddressInvalidHostname。
我想自定义该错误信息,这可行吗?