W
W
WarGot2014-09-17 19:10:33
JavaScript
WarGot, 2014-09-17 19:10:33

How to create selects with ajax loading in symfony?

Good afternoon.
There are 3 drop-down lists:
- country
- region
- city

There is a controller, there is a form. When choosing a country in the drop-down list, we send an ajax request, get a list of regions belonging to the country, update the drop-down list with a choice of regions, after choosing a region, load the list of cities.

The main problem is that in symphony, in the formtype for the drop-down list, you must specify choices, otherwise the form will not be valid when submitting. How to do it right? Please share an example.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Senkevich, 2014-09-17
@WarGot

This can be done via form events, here is an example from Cookbook symfony.com/doc/current/cookbook/form/dynamic_form...

S
Sergey, 2014-09-17
Protko @Fesor

You have the opportunity to create your own form type (ala ajax-select), make your own form view for it, data transformers, whatever. What's the problem then?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question