ZF-2734: Improvements for Zend_Validate_EmailAddress and Zend_Validate_HostName Integration
Description
It should be desirable that Zend_Validate_EmailAddress could propagate his current translator to the Zend_Validate_HostName prior validating it.
Also, Zend_Validate_HostName messages aren't returned with the corresponding keys, making them impossible to translate through a Zend_Form object.
I suggest change this code at Zend/Validate/EmailAddress.php from:
// Match hostname part
$hostnameResult = $this->hostnameValidator->isValid($this->_hostname);
if (!$hostnameResult) {
$this->_error(self::INVALID_HOSTNAME);
foreach ($this->hostnameValidator->getMessages() as $message) {
$this->_messages[] = $message;
}
foreach ($this->hostnameValidator->getErrors() as $error) {
$this->_errors[] = $error;
}
}
To:
// Propagate current translator to the hostname validator
$this->hostnameValidator->setTranslator($this->getTranslator());
// Match hostname part
$hostnameResult = $this->hostnameValidator->isValid($this->_hostname);
if (!$hostnameResult) {
$this->_error(self::INVALID_HOSTNAME);
foreach ($this->hostnameValidator->getMessages() as $key=>$message) {
$this->_messages[$key] = $message;
}
foreach ($this->hostnameValidator->getErrors() as $error) {
$this->_errors[] = $error;
}
}
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2008-03-05T10:23:24.000+0000
Not a Zend_Form issue; this has to do with Zend_Validate. Assigning to Darby.
BTW, you can set a global translator for Validate objects using:
which will correct the problem for you in the short-term.
Posted by Thomas Weidner (thomas) on 2008-12-08T14:11:50.000+0000
Already fixed in actual release. The translator is used visa-versa.