ninsuo / symfony-collection-demo

Demo website for https://github.com/ninsuo/symfony-collection
MIT License
15 stars 8 forks source link

Empty collection when persist #13

Open aymen2255 opened 5 years ago

aymen2255 commented 5 years ago

Hi and sorry for my English, I use symfony 2.7 and I have a manytoone relationship between client and commande a client has many commandes.  in ClientType: $builder->add('commandes', 'collection', array( 'label' => false, 'type' => new CommandeType(), 'options' => array( 'label' => false, ), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'required' => true, 'by_reference' => false, 'delete_empty' => true, 'attr' => array( 'class' => 'collection', ),

in the twig view `{% form_theme form 'jquery.collection.html.twig' %}

$('.collection').collection({ allow_add: true, allow_remove: true, 'add': '', min: 1, allow_up: false, allow_down: false, });`

whene i render the form with {{form(form)}} it work but when i render manualy fields like this {{ form_widget(form.commandes) }} it does not work when i'm doing dump in the controller after sublit i have empty arraycollection
Client {#385 ▼ -id: null -nom: "test" -prenom: "test" -telephone: "0111111" -createdAt: null -updatesAt: null -email: "test@test.com" -commandes: ArrayCollection {#383 ▼ -elements: [] } }