title: Zend_Form_Element: add class if it contains errors
body: <p>In my current application, I would like to color the select options red when they contain faulty information (aka not validated). When a form element contains one or more errors, it should have an error class (so I can style accordingly). I tried looping through the elements, and seeing if they validated, but this gets very ugly very quickly.</p>
  
  <p>How would I get this done in a better way?</p>
  
  <p>Thanks</p>
  
  <p>Edit: This is my current workaround (and gets the job done, but dirtily)</p>
  
  <pre><code>$post = $request-&gt;getPost();
  foreach ($contactForm-&gt;getElements() as $element) {
      if (!$element-&gt;isValid($post[$element-&gt;getName()])) {
          $element-&gt;setAttrib('class', 'error');
      }
  }
  </code></pre>