ZF-2988: Add public accessors for errors and messages for elements


I didn't want to add a custom validators and decided to override my form's isValid() instead. Doing my custom logic there was straightforward, except that I couldn't set the errors on my elements as they are managed internally by Zend_Form_Element with no public accessors.

I propose that we add public accessors for errors and messages. It makes sense regardless of the use case I demonstrated.


Currently, you always have to write your own validator, in order to get an error in the stack. I also think it'd be usefull to have a method to push your own custom errors into the error stack on a per element basis:

$myElement->addError('key', 'error message');

It would also be convenient to be able to do this on form level, where the input would be an array:

$form->addErrors(Array $myCustomErrors);

vote +1

Please evaluate and categorize as necessary.

Can this please include hasErrors()?

An example use case would be determining whether or not to add an 'error' class to a tag when using the ViewScript decorator:

// label/element output here

New functionality complete as of r10162.

Updating for the 1.6.0 release.