title: Symfony 2 : How to correctly add an element in collection in the form
body: <p>In a form of entityA I'd like to be able to add some form of entityB.</p>
  
  <p>I know how to show one form but when I put the attribute 'collection' with 'allow_add'... it doesn't add anything but an empty <li></li></p>
  
  <p>here is my view : </p>
  
  <pre><code>&lt;.form action="{{ path('our_bundle_building_entityACreate')}}" method="post" {{ form_enctype(form) }} &gt;
  {{ form_widget(form) }}
  
  {{ form_row(form.entity) }}
  
  &lt;ul id="price-fields-list" data-prototype="{{ form_widget(form.entityB.vars.prototype) | e }}"&gt;
      {% for entityB in form.entityB %}
          &lt;li&gt;
              {{ form_errors(entityB) }}
              {{ form_widget(entityB) }}
          &lt;/li&gt;
      {% endfor %}
  &lt;/ul&gt;
  &lt;a href="#" id="add-another-entityB"&gt;Add another entityB price&lt;/a&gt;
  
  &lt;input type="submit" /&gt;
  &lt;./form&gt;
  
  &lt;.script type="text/javascript"&gt;
  var entityBCount = '{{ form.entityB | length }}';
  
  jQuery(document).ready(function() {
      jQuery('#add-another-entityB').click(function() {
          var entityBList = jQuery('#entityB-fields-list');
  
          var newWidget = entityBList.attr('data-prototype');
  
          newWidget = newWidget.replace(/__name__/g, entityBCount);
          entityBCount++;
  
          var newLi = jQuery('&lt;li&gt;&lt;/li&gt;').html(newWidget);
          newLi.appendTo(jQuery('#entityB-fields-list'));
  
          return false;
      });
  })
  &lt;./script&gt;`
  </code></pre>
  
  <p>my form of entityB is nicely working so I won't show it ( only a few usual inputs )</p>
  
  <p>my form of entityA in the buildForm : </p>
  
  <pre><code>-&gt;add('entityB', 
                  'collection', 
                  array('type' =&gt; new entityBType($this-&gt;id),
                        'allow_add' =&gt; true,
                        'allow_delete'  =&gt; true,
                        'by_reference' =&gt; false,));
  </code></pre>
  
  <p>By the way, I didn't really understood the "prototype" so the problem may come from here.</p>
  
  <p>Thanks and regards,</p>
  
  <p>Me :)</p>