EasyCorp / EasyAdminBundle

EasyAdmin is a fast, beautiful and modern admin generator for Symfony applications.
MIT License
4.04k stars 1.02k forks source link

Chained forms in EasyAdmin #6079

Open Iwios opened 8 months ago

Iwios commented 8 months ago

Short description of what this feature will allow to do: Hello, I try to chained forms in EasyAdmin Crud controller. I want

For example: I have a page with two Associationfield

First field was link with the second in mysql database with key.

Table 1: city Table 2: school

Table 1: id | name 1 | chicago 2 | Seattle

Table 2 id | name | city_id 1 | Western | 1 2 | Southern | 2

If I select chicago in my first field, I wanna only Western school in the second field

Hope someone can help me to find a solution :)

bytes-commerce commented 8 months ago

Hey buddy, I'd love to assist you there but sadly I am unable to fully grasp what you're asking for.

Please correct me if I am wrong?

  1. you have an entity with a X-ToMany assoc
  2. you want to link both entities together, but not require it to set it up on both sides (one side is enough to make it appear in the other, no matter on which side you're setting up the relationship)

Is that what you're aiming for?

Iwios commented 8 months ago

Hello thank you very much for your help. I try to explain better :)

I have in my mysql DB to tables: School and Room

Room was link with School by ManyToOne relation

I have 2 school : A and B I have 3 room: R1 / R2 /R3

School A have R1 and R3 School B have R2

In my DB if I request room linked with school A I have R1 and R3

Now I would make the same but with forms

In my EasyAdmin I have a controller with 2 forms

Form 1 -> Select School Form 2 -> Select Room

Now the trick I would:

If in form 1 I select School A in form 2 I would only return R1 and R2 in 2nd form If I select School B I would only return R2 in 2nd form

That was a little bit more clear ?

KDederichs commented 8 months ago

I guess it's this: https://github.com/EasyCorp/EasyAdminBundle/issues/6022

or this: https://github.com/EasyCorp/EasyAdminBundle/issues/4716#issuecomment-1824847531 (that's a way how I set it up currently)

Iwios commented 8 months ago

Hello :) Thank for the answer, I will try to adapt for my case.