I'm working with symfony2.16 I want to select the person if this is not a foreign key in the user table my code is like this: public function buildForm (FormBuilderInterface $ builder, array $ options) {
$idPessoa = $options['idPessoa'];
$builder
->add('idPessoa', 'entity', array('class' => 'SUGASugaBundle:Pessoa',
'query_builder' => function(EntityRepository $er) use ($idPessoa){
return $er->createQueryBuilder('a')
->join('SUGASugaBundle:User','u')
->where('a.id != u.idPessoa')
->andwhere('a.id != :id')
->setParameter('id', $idPessoa)
->orderBy('a.nome');
},
'choice_label' => 'getNomeCompleto'
))
->remove('plainPassword')
->remove('username')
->add('save', 'submit', array('label' =>'Salvar'));
;
So he is bringing you who already has user account