vendredi 8 mai 2015

Join entity properties in form

Is it possible to join two properties in an entity collection form field ?

So that the select input displays soemthing like this:

property1 - Property 2

So far, my builder field looks like this

->add('arrival', 'entity', array(
'class' => 'AOFVHFlyBundle:Airport',
'property' => 'name',
'query_builder' => function($repository) {
                                return $repository->createQueryBuilder('u')
                                    ->orderBy('u.name', 'ASC');
                            },
))

But obviously, it only returns the name property. My Airport Entity has a "name" property and a "Code" property, I would like to display something like [Airpot Name] - [Airport Code]

Is it possible?

Aucun commentaire:

Enregistrer un commentaire