title: Zend Framework 2 form element error-class + custom ViewHelper to render form
body: <p>This is my third question this week (and overall) - hope I don't get banned here :D
  Anyway, searched around and couldn't find an exact explanation to solve my issue(s).</p>
  
  <p>A. I've searched around and found a custom ViewHelper to render my forms. What it does is recursively get all fieldsets and when it gets to the element level, it goes like this:</p>
  
  <pre><code>    public function renderElement($element) {
          $html = '
              &lt;div class="row"&gt;' . 
              '&lt;label class="col-md-12" for="' . $element-&gt;getAttribute('id') . '"&gt;' . $element-&gt;getLabel() . '&lt;/label&gt;' . 
              $this-&gt;view-&gt;formElement($element) . 
              $this-&gt;view-&gt;FormElementErrors($element) .
              '&lt;div class="clearfix" style="height: 15px;"&gt;&lt;/div&gt;';
  
          return $html . PHP_EOL;
      }
  </code></pre>
  
  <p>Form renders ok, except:
  1) How can I add an error class to the form element? (like if I use formRow helper in my view, it automatically ads an 'input-error' class, while also keeping the initial class specified in my fieldset when creating the element - 'attributes' => array('class' => 'some-class')), so the element's class attribute becomes "some-class input-error" in case it's invalid.
  2) How can I set a class for the 'ul' containing the error messages (the 'ul' rendered by $this->view->FormElementErrors($element))? Hope this is a one-liner and I don't have to go message-by-message and compose the html for the error messages list, but if not so be it (I don't know how to do that either).</p>
  
  <p>B. Let's say that sometimes I don't use this custom ViewHelper to render my form. Zend's formRow view helper can be handy sometimes. This brings me to the following code in my view:</p>
  
  <pre><code>    echo $this-&gt;formRow($this-&gt;form-&gt;get('user_fieldset')-&gt;get('user_name'));
  </code></pre>
  
  <p>I've noticed this automatically adds 'input-error' class on my element (in case it's invalid) which is perfect, BUT how can I also tell formRow to give a class to the 'ul' that's displaying the error messages?</p>
  
  <p>I'd go even further and ask how I can turn this:</p>
  
  <pre><code>    echo $this-&gt;formLabel($this-&gt;form-&gt;get('user_fieldset')-&gt;get('user_name'));
      echo $this-&gt;formInput($this-&gt;form-&gt;get('user_fieldset')-&gt;get('user_name'));
      echo $this-&gt;formElementErrors($this-&gt;form-&gt;get('user_fieldset')-&gt;get('user_name'), array('class' =&gt; 'form-validation-error'));
  </code></pre>
  
  <p>into something that ads an error-class to the element as well, not just to the error messages list, but if anyone answers to point A I think it's the same issue.</p>