cambiar el color de fondo de los elementos del formulario zend si no es válido

Hi I am using Zend Framework and would like to have my form show which elements are invalid by changing their background color to red. To do this I need to set the class/id of the invalid <input class='error'> in my form and write a css to change the color. I am just having trouble getting a list of all the invalid elements.

The only way I can think of doing this is after the for is found to be invalid if (!$form->isValid($posts)){} es utilizar getMessages() to get the names of all the invalid elements and then set all elements $element->setAttrib('class', 'error'). I was hoping to be able to call something built in to the form, similar to getElements() but couldnt find a getInvalidElements() or something similar. I also imagine it would be possible to write a decorator to the whole form to achieve the same thing but I dont know where to start.

Any recommendations on how i should proceed? Thanks.

preguntado el 10 de marzo de 12 a las 12:03

1 Respuestas

ampliar Zend_Form and add a css class error to all invalid fields, write styles for the .error clase.

Este planteamiento de « blog gives you an idea of how it could be done.

respondido 10 mar '12, 16:03

champion! that is exactly what i was looking for. - viciouskinid

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.