I'm creating a form with fields based on an entity,I tried to set the default values using the data option,and preferred choices following the answers to the questions asked here and here,I tried injecting entity manager from the controller and fetching an entity in the form type,I also tried injecting the entity directly ... still doesn't work.
i wonder if the problem is caused by the query_builder i'm passing into the option when creating the field ( I used it to avoid duplicates as group_by doesn't do the trick). here the code of the form :
To see the whole class :
http://pastebin.com/sx4du0Eb
An example of a filed :
->add('quantite', 'entity', array(
'class' => 'CcWebBundle:Brochure',
'property' => 'quantite',
'multiple' => false,
// utilisation d'une requête pour filtrer les resultats
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('u')
->groupBy('u.quantite');
}
))