title: data-prototype not correctly rendered using nested collection form fields in a symfony2 form-type
body: <p>Im building a project with symfony2.2, I'm posting here because i'm having trouble with nested collection, within collection.
  I want to render a form, for this kind of Doctrine Entities :</p>
  
  <p><a href="http://i.stack.imgur.com/QmESP.jpg" rel="nofollow">http://i.stack.imgur.com/QmESP.jpg</a></p>
  
  <p>But here, the period object is not rendering, while rendering it alone works perfectly.
  The data-prototype is, in fact, correct but it's not rendering the data-prototype nested inside the main data-prototype.</p>
  
  <p><strong>So the question is : how do I correctly print the nested data-prototype within the main data-prototype ?</strong></p>
  
  <p>Twig template :</p>
  
  <pre><code>&lt;fieldset class="nestedFormWeekDay" data-prototype="{{ form_widget(form.weekDays.day.vars.prototype)|e }}"&gt;
  &lt;legend&gt;Weekday&lt;/legend&gt;
  &lt;/fieldset&gt;
      {{ func.add_delete_form_elem('fieldset.nestedFormWeekDay', '&lt;fieldset&gt;&lt;legend&gt;day&lt;/legend&gt;', '&lt;/fieldset&gt;') }}
  &lt;/fieldset&gt;
  </code></pre>
  
  <p>HTML for the main prototype: </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
      &lt;div id="timebundle_jsschedulertype_weekDays_day___name__"&gt;
          &lt;div class="formSlot"&gt;
              &lt;input id="timebundle_jsschedulertype_weekDays_day___name___isUltimo" type="hidden" name="timebundle_jsschedulertype[weekDays][day][__name__][isUltimo]"&gt;
              &lt;div class="formSlot"&gt;
                  &lt;p class="formSlot"&gt;
                  &lt;p class="form"&gt;&lt;/p&gt;
                  &lt;div id="timebundle_jsschedulertype_weekDays_day___name___period" data-prototype="&lt;div class="formSlot"&gt; &lt;p class="formSlot"&gt;&lt;label class="required"&gt;__name__label__&lt;/label&gt;&lt;/p&gt; &lt;p class="form"&gt;&lt;div id="timebundle_jsschedulertype_weekDays_day___name___period___name__"&gt;&lt;div class="formSlot"&gt;&lt;p class="formSlot"&gt;&lt;label class="required"&gt;Starttime&lt;/label&gt;&lt;/p&gt;&lt;p class="form"&gt;&lt;div id="timebundle_jsschedulertype_weekDays_day___name___period___name___startTime"&gt;&lt;div class="formSlot"&gt;&lt;p class="formSlot"&gt;&lt;label class="required"&gt;Singlestarttime&lt;/label&gt;&lt;/p&gt;&lt;p class="f...&gt;&lt;option value="45"&gt;45&lt;/option&gt;&lt;option value="46"&gt;46&lt;/option&gt;&lt;option value="47"&gt;47&lt;/option&gt;&lt;option value="48"&gt;48&lt;/option&gt;&lt;option value="49"&gt;49&lt;/option&gt;&lt;option value="50"&gt;50&lt;/option&gt;&lt;option value="51"&gt;51&lt;/option&gt;&lt;option value="52"&gt;52&lt;/option&gt;&lt;option value="53"&gt;53&lt;/option&gt;&lt;option value="54"&gt;54&lt;/option&gt;&lt;option value="55"&gt;55&lt;/option&gt;&lt;option value="56"&gt;56&lt;/option&gt;&lt;option value="57"&gt;57&lt;/option&gt;&lt;option value="58"&gt;58&lt;/option&gt;&lt;option value="59"&gt;59&lt;/option&gt;&lt;/select&gt;&lt;/div&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/p&gt; &lt;/div&gt; "&gt;
          &lt;/div&gt;
              &lt;p&gt;&lt;/p&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>SchedulerType :</p>
  
  <pre><code>-&gt;add('weekDays', new JSWeekdaysType(), array('required' =&gt; false))
  </code></pre>
  
  <p>WeekDaysType :</p>
  
  <pre><code>-&gt;add('day', 'collection', array('type' =&gt; new JSDayType(), 'allow_add' =&gt; true, 'by_reference' =&gt; false, 'allow_delete' =&gt; true))
  </code></pre>
  
  <p>DaysType:</p>
  
  <pre><code>-&gt;add('period', 'collection', array('type' =&gt; new JSPeriodType(), 'allow_add' =&gt; true, 'by_reference' =&gt; false, 'allow_delete' =&gt; true))
  </code></pre>
  
  <p>PeriodType:</p>
  
  <pre><code>-&gt;add('startTime', new JSSingleStartType())
  -&gt;add('timeSlot',  new JSTimeSlotType());
  </code></pre>
  
  <p>SchedulerController:</p>
  
  <pre><code>$Scheduler = new JSScheduler();
  $SchedulerType = new JSSchedulerType();
  $form = $this-&gt;createForm($SchedulerType, $Scheduler);
  return $this-&gt;render('TimeBundle:Form:newJsScheduler.html.twig', array('form' =&gt; $form-&gt;createView()));
  </code></pre>
  
  <p>And finally the javascript function that allow me to add new entities : </p>
  
  <pre><code>function add_element($container, $wrap_beg, $wrap_end)
  {
      var index = $container.find(':input').length;
      var input = $container.attr('data-prototype').replace(/__name__/g, index);
      $input = '&lt;div class =\'new\'&gt;'+$wrap_beg+input+$wrap_end+'&lt;hr/&gt;&lt;/div&gt;';
      $container.append($input);
  }
  </code></pre>
  
  <p>full html : <a href="http://pastebin.com/sL8Z3Nxc" rel="nofollow">http://pastebin.com/sL8Z3Nxc</a></p>