title: Twig Form Theming - form_label class attribute
body: <p>I've been trying to override the form_row Twig extension so I can render a Twitter Bootstrap style row. A twitter boostrap form row should look like this:</p>
  
  <pre><code>&lt;div class="control-group"&gt;
      &lt;label class="control-label" for="idOfMainInput"&gt;Label Name:&lt;/label&gt;
      &lt;div class="controls"&gt;
          &lt;input type="text" id="idOfMainInput" name="someDumbName"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The base twig div style form_row block is defined in <a href="https://github.com/symfony/symfony/blob/2.2/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig" rel="noreferrer">this link</a> as below:</p>
  
  <pre><code>{% block form_row %}
  {% spaceless %}
      &lt;div&gt;
          {{ form_label(form) }}
          {{ form_errors(form) }}
          {{ form_widget(form) }}
      &lt;/div&gt;
  {% endspaceless %}
  {% endblock form_row %}
  </code></pre>
  
  <p>So, my thoughts were to just put the necessary divs in, and hard code where necessary the class entries (i.e. in the main div) but pass the 'attr' value to the form_label, form_errors and form_widget sections. I've taken out form_errors for now, just so I don't get too deep into it. Here's what I tried:</p>
  
  <pre><code>{% form_theme form _self %}
  {% block form_row %}
  {% spaceless %}
  &lt;div class="control-group"&gt;
      {{ form_label(form, 'test label name', { 'attr': {'class': 'control-label'} }) }}
      &lt;div class="controls"&gt;
      {{ form_widget(form) }}
      {{ form_errors(form) }}
      &lt;/div&gt;
  &lt;/div&gt;
  {% endspaceless %}
  {% endblock form_row %}
  </code></pre>
  
  <p>The problem, though, is no matter what I try, the form_label extension does not use "control-label" as my class (and it should according to the source code append it if there's existing ones, like "required"). Here's what I get when I view the source of the rendered page:</p>
  
  <pre><code>&lt;div class="control-group"&gt;
      &lt;label for="form_rsa_id" class="required"&gt;test label name&lt;/label&gt;
      &lt;div class="controls"&gt;
          &lt;input type="number" id="form_rsa_id" name="form[rsa_id]" required="required" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>As you can see, the class="required" is there and is taken from the base form object attributes, but it should be class="required control-label", which it's not.</p>
  
  <p>Kinda at a loss here, as the documentation (as well as the source) states that one should use the notation "form_label(view, label, variables)". Link to docs <a href="http://symfony.com/doc/2.0/reference/forms/twig_reference.html#form-label-view-label-variables" rel="noreferrer">here</a>.</p>