title: How to add rows to CollectionType in Symfony2 Form?
body: <p>I'm trying to create a "complex form" using Symfony2. One field of this form is created from another "simple form", and, 6 fields of the form are created from another "simple form" (so it's a repeated field, yes). It's like a "Form of forms" or embedded form.</p>
  
  <p>The following code correspond to the first "simple form" that is only one field of the "complex form": </p>
  
  <pre><code>&lt;?php
  
  namespace SisEvo\ConfiguracionBundle\Form;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  
  class VariableReguladaElectricoValoresDatosType extends AbstractType{
  
      /**
       * @param FormBuilderInterface $builder
       * @param array $options
       */
       public function buildForm(FormBuilderInterface $builder, array $options) {
      $builder
              -&gt;add('valor');          
  }
  
  /**
   * @param OptionsResolver $resolver
   */
  public function configureOptions(OptionsResolver $resolver) {
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt;     'SisEvo\ConfiguracionBundle\Entity\VariableReguladaElectricoValoresDatos'
          ));
      }
  
  }
  </code></pre>
  
  <p>The other "simple form" that will be repeated 6 times in the "complex form": </p>
  
  <pre><code>&lt;?php
  
  namespace SisEvo\MaestroBundle\Form;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  
  
  class VariablesMedidaType extends AbstractType{
  
      /**
       * @param FormBuilderInterface $builder
       * @param array $options
       */
      public function buildForm(FormBuilderInterface $builder, array     $options) {
           $builder-&gt;add("medida", EntityType::class, array(
                      'required' =&gt; true,
                      'class' =&gt; 'MaestroBundle:VariablesMedida',
                      'choice_label' =&gt; 'medida',
                  ));
      }
  
      /**
       * @param OptionsResolver $resolver
       */
       public function configureOptions(OptionsResolver $resolver) {
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt; 'SisEvo\MaestroBundle\Entity\VariablesMedida'
           ));
      }
  
  }
  </code></pre>
  
  <p>And finally, the "complex form": </p>
  
  <pre><code>&lt;?php
  
  namespace SisEvo\ConfiguracionBundle\Form;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  use SisEvo\MaestroBundle\Form\VariablesMedidaType;
  use SisEvo\ConfiguracionBundle\Form\VariableReguladaElectricoValoresDatosType;
  
  class VariableReguladaElectricoValoresType extends AbstractType {
  
  /**
   * @param FormBuilderInterface $builder
   * @param array $options
   */
  public function buildForm(FormBuilderInterface $builder, array $options) {
      $builder
              -&gt;add('idDatos', CollectionType::class, array(
                  // each entry in the array will be an "email" field
                  'entry_type' =&gt; VariableReguladaElectricoValoresDatosType::class,
                  // these options are passed to each "email" type
                  'entry_options' =&gt; array(
                      'attr' =&gt; array(
                          'rows' =&gt; 6
                      //,'class' =&gt; 'VariableReguladaElectricoValoresDatos'
                      )),
              ))
              //-&gt;add('valores', 'collection', array('type' =&gt; new VariableReguladaElectricoValoresDatosType()))
              -&gt;add('idMedida', new VariablesMedidaType());
  }
  
  /**
   * @param OptionsResolver $resolver
   */
  public function configureOptions(OptionsResolver $resolver) {
      $resolver-&gt;setDefaults(array(
          'data_class' =&gt; 'SisEvo\ConfiguracionBundle\Entity\VariableReguladaElectricoValores'
          , 'cascade_validation' =&gt; true
      ));
      }
  
  }
  </code></pre>
  
  <p><code>idMedida</code> field is working fine, but I need some help to print <code>idDatos</code> field, that should be printed 6 times. I tried to do it with the option rows as you can see in the code, but is not working.</p>
  
  <p>In the twig file I'm trying to print the form using <code>{{ form_widget(myComplexForm) }}</code></p>
  
  <p>Any idea to solve it?</p>