In my current application, I would like to color the selection options in red when they contain erroneous information (it has not been verified). If a form element contains one or more errors, it must have an error class (so I can change the style accordingly). I tried to navigate through the elements and see if they were checked, but it is very ugly very quickly.
How to do it better?
thank
Edit: This is my current solution (and does the job, but is dirty)
$post = $request->getPost();
foreach ($contactForm->getElements() as $element) {
if (!$element->isValid($post[$element->getName()])) {
$element->setAttrib('class', 'error');
}
}
user827080
source
share