title: Symfony2 Get a form via Ajax
body: <p>I call a form with ajax, instead of display it in page.</p>
  
  <p>Everything is working, except 1 strange thing.</p>
  
  <p>When i call the form via ajax and add it to the page, defaults values are not in fields.</p>
  
  <p>But if i call the form via normal url, default value are set...</p>
  
  <pre><code>$builder
          -&gt;add('email', null,array('data' =&gt; 'default value')
          -&gt;add('type_form', null, array('data' =&gt; 'default value', 'property_path'=&gt; false))
          -&gt;add('list_choice', 'choice', array(
              'choices' =&gt; $options['list'],
              'expanded'=&gt;true,
              'multiple'=&gt;true,
          ));
  </code></pre>
  
  <p>The field email and type_form do not display the 'default value' as value except if i call the form via his url, and not via ajax.</p>
  
  <p>Is there a specific way to call form via ajax ?
  Thanks for your answers.</p>
  
  <p>Here the way i create the form in my controller</p>
  
  <pre><code>$this-&gt;container-&gt;get('templating')-&gt;render('MyappSiteBundle:Contributions:filter_themes_form.html.twig', array(
  'form'=&gt; $form-&gt;createView(),
  'type'=&gt; $type ));
  
  $response = new Response(json_encode(array('form'=&gt; $response_form)));
  
  
  $response-&gt;headers-&gt;set('Content-Type', 'application/json');
  return $response;
  </code></pre>
  
  <p>Then i was calling the form...</p>