Reputation: 31548
If I use this code then I can create new object without any problem:
->add('user', 'entity', array(
'class' => 'Acme\Entity\User',
'query_builder' => function(EntityRepository $er) use ($options){
return $er->createQueryBuilder('u')->orderBy('u.name', 'ASC');}
))
But if I set some parameter like this:
'query_builder' => function(EntityRepository $er) use ($options) {
return $er->createQueryBuilder('u')
->where('u.id = :id')
->setParameter('id',$options['id'])
->orderBy('u.name', 'ASC');}
))
Then I can see the options correctly in select box , but when i submit the form , i get NULL values for User Object. Am missing something?
Upvotes: 0
Views: 414
Reputation: 31919
$options['id']
might be a string. Try this:
->setParameter('id',intval($options['id']))
Upvotes: 1