title: How to custom HTML form_errors in Symfony
body: <p>I would like custom the render of form_errors in Symfony 3, because I would like obtain (in my Twig remplate) :</p>
  
  <pre><code>&lt;div class="alert alert-danger"&gt;My error&lt;/div&gt;
  </code></pre>
  
  <p>Instead of :</p>
  
  <pre><code>&lt;ul&gt;&lt;li&gt;My error&lt;/li&gt;&lt;/ul&gt;
  </code></pre>
  
  <p>It's possible ?</p>
  
  <p><strong>I tried this :</strong></p>
  
  <pre><code>{{ form_errors(form.name) ? '&lt;div class="alert alert-danger"&gt;' ~ form_errors(form.name) ~ '&lt;/div&gt;' : ''  }}
  </code></pre>
  
  <p>But the HTML is not interpreted and it may not be very clean ..</p>
  
  <p><strong>And this (Recovery of vendor\symfony\symfony\src\Symfony\Bridge\Twig\Resources\views\Form\form_div_layout.html.twig line 307):</strong></p>
  
  <p><strong>I overloaded:</strong></p>
  
  <pre><code>{%- block form_errors -%}
      {%- if errors|length &gt; 0 -%}
      &lt;ul&gt;
          {%- for error in errors -%}
              &lt;li&gt;{{ error.message }}&lt;/li&gt;
          {%- endfor -%}
      &lt;/ul&gt;
      {%- endif -%}
  {%- endblock form_errors -%}
  </code></pre>
  
  <p><strong>By :</strong></p>
  
  <pre><code>{%- block form_errors -%}
  {%- if errors|length &gt; 0 -%}
  &lt;ul&gt;
      {%- for error in errors -%}
          &lt;li&gt;{{ error.message }}&lt;/li&gt;
      {%- endfor -%}
  &lt;/ul&gt;
  {%- endif -%}
  {%- endblock form_errors -%}
  </code></pre>
  
  <p>But the variable "error" is not defined</p>
  
  <p>Thanks in advance for your help</p>