I am using Symfony3 and I want to be able to display custom select values by combining two fields together such as name and city. So, in essence in the select box it would show this:
------------------------------------
John Smith - Denver
------------------------------------
Abe Lincoln - Washington D.C
------------------------------------
George Washington - Washington D.C
------------------------------------
etc...
------------------------------------
Here's my form...
$builder->add('person', EntityType::class, array(
'required'=>false,
'class'=>'AppBundle:Person',
'choice_label'=>'name',
'label'=>'Choose the person',
'empty_data'=>null,
'placeholder'=>"None",
'query_builder' => function(EntityRepository $repository) {
return $repository->createQueryBuilder('p');
}
));