If you look at the code, addErrorMessages() ignores keys. It simply does:

foreach($messages as $message){
$this->addErrorMessage($message);
}

>From looking at the code, and your sample, if the element is invalid, you
should be getting both error messages regardless of which validator
triggered the error. So it could be there might be some bugs involved here.

If you want to customize the error message for individual validators, you'll
need to do that on the validators themselves.
Do this either by passing the custom string in the options array, or by
getting the validator and setting the message for the particular key.

$element->addValidator('NotEmpty, true, array('messages' => array($key =>
$message)));
//or
$element->getValidator('NotEmpty')->setMessage($message, $key);

Either of the above should work, but I haven't tested it. The first one
gives you the advantage of lazy-loading the validator, so should be better
performance wise.

Cheers,
David



-- 
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Zend-Validate-Abstract-custom-validator-not-displaying-correct-error-messages-tp2223115p2224360.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to