Symfony 2 - create a form with a parent that filters the parameters of a child

I am new to symfony and PHP. I have a problem that I hope someone can help:

suppose we have 3 objects.

Groups, specialties, work; works belong to the specialty, the specialty belongs to the group.

Suppose I want to have a form to create a “job”. I want to filter my specialties according to the choice with the list of groups (just like on the travel site, where we get destinations filtered by source).

Thus, my form will contain only 2 fields. Specialty and title of work. But, in my opinion, I should have 3 fields, 1 for groups that will filter the specialty and fields related to the form.

Like the booking site, I have to see the fields from the start.

It is so simple, but I really stuck on it.

thank

+5
source share
1 answer

At this moment I can find 2 solutions:

1) Use ajax. Fill selectbox with groups upon request. when you select one of the groups, all specialties fall into another selectbox of this group.

2) Use uri segments. Let the user select a group first, then go to the next page and let them choose a specialty. After that, the user receives a form in which he fills in the data.

+2
source

All Articles