O
O
ol sm2017-08-25 20:22:22
symfony
ol sm, 2017-08-25 20:22:22

How to bind selects in symfony?

Good evening.
There are several select forms (countries, region, city), tell me how to connect these selects with each other so that when choosing a country, there is a selection of the corresponding regions and cities.
P.Y. Thanks in advance.
formType

->add('city', EntityType::class, array(
                    'class' => 'AppBundle:Countries',
                    'choice_label' => 'name',
                    'expanded' => false,
                    'multiple' => false,

                    'label' => 'Выбрать страну',
                    'attr' => array(
                        'class' => 'form-control',
                        'style' => 'margin-bottom: 15px'
                    )
                ))

->add('city', EntityType::class, array(
                    'class' => 'AppBundle:Region',
                    'choice_label' => 'name',
                    'expanded' => false,
                    'multiple' => false,

                    'label' => 'Выбрать регион',
                    'attr' => array(
                        'class' => 'form-control',
                        'style' => 'margin-bottom: 15px'
                    )
                ))

->add('city', EntityType::class, array(
                    'class' => 'AppBundle:City',
                    'choice_label' => 'name',
                    'expanded' => false,
                    'multiple' => false,

                    'label' => 'Выбрать город',
                    'attr' => array(
                        'class' => 'form-control',
                        'style' => 'margin-bottom: 15px'
                    )
                ))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Skobkin, 2017-08-25
@skobkin

For example, using a dependent field from this bundle or analogues.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question