Hello, What is the most straight-forward way to mark an element as invalid and display a custom error message *without using validators*?
For example, we are using a web service to process data submitted via a web form. I have set up validators in my form for the basic things like required fields and string length, but sometimes there is additional validation that occurs on the web-service side that could prevent the process from continuing. In that event I'd like to take the error message from the web service and inject it into the offending form element to be displayed to the user. I've looked over the API and documentation<http://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.validators.errors>and there are two methods that seem likely candidates for doing my bidding: *Zend_Form_Element#setErrors(array $errors)* *Overwrite any previously set error messages and flag as failed validation* *Zend_Form_Element#setErrorMessages(array $errorMessages)* *Same as addErrorMessages(), but clears custom error message stack first* If I use setErrors() and pass in an array with a single error message, the message is duplicated when rendering. If I use setErrorMessages() and pass in an array with a single error message, the message is not displayed at all when rendering. I found that if I call both methods and pass in the same single-value array to both of them, it works as expected -- I get my nice error message on the rendered form. Is this typically how it should be done? Or am I missing something? Thanks! -- *Hector Virgen* Sr. Web Developer http://www.virgentech.com
