我有这个代码
->add('user', 'entity', array(
'class' => 'Acme\Entity\User',
'query_builder' => function(EntityRepository $er) use ($options)
{ return $er->createQueryBuilder('u')
->orderBy('u.name', 'ASC');
},
'data' => $option['id']
))
它不工作
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('description')
->add('user', 'entity', array(
'class' => 'Acme\Entity\User',
'query_builder' => function(EntityRepository $er) use ($options) {
return $er->createQueryBuilder('u');
},
'preferred_choices' => array('2')
))
;
}