EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Chained forms in EasyAdmin

Open Iwios opened this issue 2 years ago • 4 comments

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 :)

Iwios avatar Jan 01 '24 23:01 Iwios

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?

bytes-commerce avatar Jan 04 '24 14:01 bytes-commerce

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 ?

Iwios avatar Jan 04 '24 15:01 Iwios

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)

KDederichs avatar Jan 07 '24 11:01 KDederichs

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

Iwios avatar Jan 10 '24 13:01 Iwios