hi there,
I have a common requirement for setting one error message on the
failed validation of a form element, for example an email address.
Sometimes I just want to set something like 'Enter a valid email
address' rather than have the many different error messages that
Zend_Validate_EmailAddress offers.
I know you seem to be able to set a single error message on a form
element via $element->addErrorMessage('string..') but that appears to
set one error message for all validators on a form element.
If I just want to set one error message per validator the only way to
do so appears to be to setMessage for each message key that exists for
that validator. Which is a bit verbose of course :)
Would it be a reasonable use case to add a new function to
Zend_Validate_Abstract to do this, for example:
public function setSingleMessage ($messageString)
{
foreach ($this->getMessageTemplates() as $messageKey =>
$message) {
$this->setMessage($messageString, $messageKey);
}
return $this;
}
If so, is this the right place to suggest the new method??
best wishes,
Si