title: Symfony2 changing forms date input class in twig
body: <p>I am confused on how can I overwrite the code of the forms template to match my needs.. For example when I create a date input fields it is very long and I want to change it with my class. I am reading this documentation <a href="http://symfony.com/doc/current/cookbook/form/form_customization.html" rel="nofollow">http://symfony.com/doc/current/cookbook/form/form_customization.html</a> however I have no clue on how to use the example for my needs: This is what I already did:</p>
  
  <p>I added the horizontal theme in config.yml:</p>
  
  <pre><code># Twig Configuration
  twig:
      debug:            "%kernel.debug%"
      strict_variables: "%kernel.debug%"
      form:
          resources: 
              - 'bootstrap_3_horizontal_layout.html.twig' 
  </code></pre>
  
  <p>This is how I make the data field input:</p>
  
  <pre><code>&gt;add('DateOfBirth', 'date', array(
      'label' =&gt; 'Date Of Birth * ',
      'widget' =&gt; 'choice',
      'attr' =&gt; array('placeholder' =&gt; 'Date of Birth')))
  </code></pre>
  
  <p>It renders this template:</p>
  
  <pre><code>&lt;div id="form_DateOfBirth" placeholder="Date of Birth" class="form-inline"&gt;
      &lt;select id="form_DateOfBirth_month" name="form[DateOfBirth][month]" class="form-control"&gt;&lt;/select&gt;
  </code></pre>
  
  <p>I need to change my class in <code>selected</code> to this:</p>
  
  <pre><code>&lt;div id="form_DateOfBirth" placeholder="Date of Birth" class="form-inline"&gt;
       &lt;select id="form_DateOfBirth_month" name="form[DateOfBirth][month]" class="span1"&gt;&lt;/select&gt;
  </code></pre>
  
  <p>How can I do this? From the documentation the only thing I know i need to do is this:</p>
  
  <pre><code>{% form_theme form _self %}
  
  {% block date_widget %}
  
  {% endblock date_widget %}
  
  
   {{ form(form) }}
  </code></pre>
  
  <p>And then what? ;/</p>
  
  <p>I am trying to do something like this:</p>
  
  <pre><code>{% block date_widget -%}
              {% set attr = attr|merge({class: (attr.class|default('') ~ ' span1')|trim}) -%}
  
      {%- endblock date_widget %}
  </code></pre>
  
  <p>But i am getting undefined variable attr... ;/</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The code: <code>{{ form_widget(form.DateOfBirth, {'attr': {'class': 'span1'}}) }}</code> is not what I need.</p>
  
  <p>This changes the class of the whole div. I need to change the class of the field <code>select</code>, which has a class <code>form-control</code></p>
  
  <p>This is what I get (<code>class="span1 form-inline"</code>):</p>
  
  <pre><code>&lt;div id="form_DateOfBirth" class="span1 form-inline"&gt;&lt;select id="form_DateOfBirth_month" name="form[DateOfBirth][month]" class="form-control"&gt;&lt;/select&gt;&lt;/div&gt;
  </code></pre>