class Form_A开发者_开发技巧ccounts_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));
}
}
If the email isn't valid, I get: emailAddressInvalidHostname for $form->getErrors('email');
I would like to customize that error, is it possible?
This is just an example. This might help you.....
$email = new Zend_Form_Element_Text('emailid');
$email->setLabel("Email-Adress :* ")
->setOptions(array('size' => 20))
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('EmailAddress')
->getValidator('EmailAddress')->setMessage("Please enter a valid e-mail address.");
精彩评论