I think the easiest way to get at this is going to be to override the
behavior of Zend_Form_Decorator_Errors, or also possibly
Zend_View_Helper_FormErrors. I'll describe the basic work flow below, and
any line numbers I refer to are from version 1.9.7.

The way error display works is the Errors form decorator
(Zend_Form_Decorator_Errors) gets the messages from the form element object.
If there are any errors, it asks Zend_View_Helper_FormErrors to format them
and then adds the content onto the form's markup (and any previously
decorated markup).

Zend_View_Helper_FormErrors then formats the errors array into a list, does
some stuff (escaping), and returns the formatted errors that
Zend_View_Helper_FormErrors decorates the form with.

One thing you could do is create MyApp_Form_Decorator_Errors, cut and paste
the whole file (you'll have to over-ride the whole thing, only function),
and between lines 59 and 60 add some logic to cut the errors down if there
is more than one. Something like:
$errors = count($errors) > 1 ? array($errors[0]) : $errors;

You could also modify the view helper to only return the first error, with
some similar logic as above, only on about line 83 of
Zend_View_Helper_FormErrors.

If the only thing you want to do is alter the number of errors being
displayed, modify the decorator but not the view helper. If, however, you
want to modify the display as well, modify the view helper but not the
decorator. 
-- 
View this message in context: 
http://n4.nabble.com/zend-form-a-different-error-for-each-validator-but-show-only-one-error-tp1049681p1288948.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to