S
S
Sergey K2016-01-07 12:07:20
symfony
Sergey K, 2016-01-07 12:07:20

How to change the appearance of an EntityType in Symfony2?

There is a field parent, EntityType

$builder->add('parent', EntityType::class, array(
                'class' => 'AdBundle:AdLocation',
                'choice_label' => 'title',
                'query_builder' => function(EntityRepository $er) {
                    return $er->createQueryBuilder('l')
                        ->where('l.visible = :visible')
                        ->setParameter('visible', true);
                }
            ))

The field is represented as a list of location categories: Country, City, District.
I want to change the output in the dropdown list in the format:
- Country
- - City
- - - District
How can I do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Skobkin, 2016-02-28
@skobkin

In general, if your countries, cities and districts are stored in different tables, you can use dependent fields. For example, one of their such implementations is ShtumiUsefulBundle .
It can be expensive to display everything in one field at once, and the client’s page can slow down.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question