title: Twig and autoescaping
body: <p>I'm learning Symfony2. Currently, I'm trying to render a form label in a twig template. The label includes an html tag, that is not rendered correctly in my twig file.</p>
  
  <p>Here follows the piece of code where the form field is created:</p>
  
  <pre><code>$builder-&gt;add('zipcode', 'integer', array(
          'label' =&gt; '&lt;abbr title="Zone Improvement Plan"&gt;CAP&lt;/abbr&gt; code',
          ));
  </code></pre>
  
  <p>In the twig file I render the field label as follows:</p>
  
  <pre><code>{{ form_label(form.zipcode) }}
  </code></pre>
  
  <p>I tried the raw, escape, e filters, but the results provided in my html page is always the string</p>
  
  <pre><code> &lt;abbr title="Zone Improvement Plan"&gt;CAP&lt;/abbr&gt; code
  </code></pre>
  
  <p>and not the corresponding HTML code!</p>
  
  <p>Any suggestion?
  Thanks in advance!</p>
  
  <p>Later I found the solution. 
  The solution is to disable the autoescape within the label block provided by Symfony at path: 
       symfony / src / Symfony / Bridge / Twig / Resources / views / Form / form_div_layout.html.twig </p>
  
  <p>So, in your twig file you have to put the following lines outside the form:
      {% form_theme form _self %}</p>
  
  <pre><code>{% block generic_label %}
  {% spaceless %}
    {% if required %}
        {% set attr = attr|merge({'class': attr.class|default('') ~ ' required'}) %}
    {% endif %}
    &lt;label{% for attrname,attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}&gt;{% autoescape false %}{{ label|trans }}{% endautoescape %}&lt;/label&gt;
  {% endspaceless %}
  {% endblock %}
  </code></pre>