HTMLHelper & Model Validation

Right now I’ve extended HTMLHelper and added a new snippet of code that checks the requestCollection for a structure called Errors which is passed from the ValidateModel() using the getErrors() method.

I’m using the HTMLHelper to add an additional class called ‘error’ when an error is present in the getErrors()[x].getField() for the specific input. Then I stylize it using CSS to outline in red there was a problem with the field.

My question is, Does the HTMLHelper talk to the Validation Plugin to see which fields have failed or Is there a way I can pass the error array to the HTMLHelper to append an error class? My code works great as it is but wanted to know if there is a better way…

Right now, I output a list of errors to the user at the top of the form in addition to highlighting the affected fields in red.

Wasn’t sure if there is a better “ColdBox” way to do this or maybe this is on the list of things to be added.