title: How do I add a class to each expanded form widget in Symfony2?
body: <p>Here are the Twig fields I'm trying to override: <a href="https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig" rel="nofollow">github</a></p>
  
  <p>I have a list of checkbox that has been modified with this custom form theme:</p>
  
  <pre><code>{% block choice_widget_expanded %}
  {% spaceless %}
      &lt;div {{ block('widget_container_attributes') }}&gt;
      {% for child in form %}
          &lt;div class="checkbox_row"&gt;
          {{ form_widget(child) }}
          {{ form_label(child) }}
          &lt;/div&gt;
      {% endfor %}
      &lt;/div&gt;
  {% endspaceless %}
  {% endblock choice_widget_expanded %}
  </code></pre>
  
  <p>I tried adding a class using <code>{{ form_row(form.fieldName), {'attr':{'class':'myclass'}}) }}</code></p>
  
  <p>But that only adds a class to the <code>div#formName_fieldName</code>. Next I tried adding a custom block with </p>
  
  <pre><code>{% block _formName_fieldName_widget %}
  {% spaceless %}
      &lt;input type="checkbox" {{ block('widget_attributes') }} value="{{ value }}"  class="myclass_{{ value }}" /&gt;
  
  {% endspaceless %}
  {% endblock choice_widget_expanded %}
  </code></pre>
  
  <p>Notice I also included the value as I want to have <code>myclass_1, myclass_2</code> etc.</p>
  
  <p>The problem with this is that the block receives an array so it should be like this</p>
  
  <pre><code>{% block _fb_post_facebook_pages_widget %}
  {% spaceless %}
      &lt;div {{ block('widget_container_attributes') }}&gt;
      {% for child in form %}
          {{ form_widget(child) }}
          {{ form_label(child) }}
      {% endfor %}
      &lt;/div&gt;
  {% endspaceless %}
  {% endblock choice_widget_expanded %}
  </code></pre>
  
  <p>But then if I wanted to add the class to a specific checkbox, I would need to write something like this: </p>
  
  <pre><code>{% block _formName_fieldName_X_widget %}
  {% spaceless %}
      &lt;input type="checkbox" {{ block('widget_attributes') }} value="{{ value }}"  class="myclass_{{ value }}" /&gt;
  
  {% endspaceless %}
  {% endblock choice_widget_expanded %}
  </code></pre>
  
  <p>Where X would be a value that I have for the fieldName... And obviously the values could be anything so I can't just create block for all values from 1-1000000000000...</p>
  
  <p>Any way to do this dynamically?</p>