title: How to browse the form errors
body: <p>I'd like to browse the form errors but I it doesn't work for me.</p>
  
  <p>I tried it without ajax and I this is the error</p>
  
  <pre><code>An exception has been thrown during the rendering of a template ("Notice: Array to string conversion") 
  in AppBundle:Admin:errors-form.html.twig at line 5.
  </code></pre>
  
  <p>I think that the problem is how to loop this line using twig: </p>
  
  <pre><code>    'data' =&gt; $this-&gt;getErrorMessages($form),
  </code></pre>
  
  <p>This is the code</p>
  
  <pre><code>protected function getErrorMessages(\Symfony\Component\Form\Form $form)
  {
      $errors = array();
  
      foreach ($form-&gt;getErrors() as $key =&gt; $error) {
          $errors[] = $error-&gt;getMessage();
      }
  
      foreach ($form-&gt;all() as $child) {
          if (!$child-&gt;isValid()) {
              $errors[$child-&gt;getName()] = $this-&gt;getErrorMessages($child);
          }
      }
  
      return $errors;
  }
  
  
  public function addAction(Request $request)
  {
      if ($form-&gt;isValid()) {
          //..
      } else {
  
          $view = $this-&gt;renderView(
              'AppBundle:Admin:errors-form.html.twig', array(
                  'data' =&gt; $this-&gt;getErrorMessages($form),
              )
          );
          $response = new JsonResponse(array(
                  'view' =&gt; $view,
                  'result' =&gt; 0,
                  'message' =&gt; 'Invalid form',
              )
          );
          return $response;
  
      }
  
  
  }
  </code></pre>
  
  <p>This is the view returned with JsonResponse in case of errors , but the errors are not displayed, <strong>but if I put a static text in this view it will appear after submit</strong></p>
  
  <pre><code>&lt;div id="error"&gt;
  
      {% for error in data %}
  
          {{ error }}
  
      {% endfor %}
  &lt;/div&gt;
  </code></pre>