EasyCorp / EasyAdminBundle

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

Switch Choice content based on selection #6022

Open KDederichs opened 1 year ago

KDederichs commented 1 year ago

Short description of what this feature will allow to do: Similar to https://ux.symfony.com/demos/live-component/dependent-form-fields when you switch the input of one field, the options on the other ones get updated.

Example of how to use this feature

For config something simple like this would probably work:

     ChoiceField::new('foo'),
     ChoiceField::new('bar')
          ->setDependsOn('foo')
          ->setDependantOptionProvider(function ($fooValue) {
               // fancy code
              return [
                 'label' => 'value'
             ]
          })

and then in the frontend it'd update the choices for bar everytime Foo changes

KDederichs commented 1 year ago

For anyone stumbling on this in the meantime: https://github.com/EasyCorp/EasyAdminBundle/issues/4716#issuecomment-1824847531

That's my current solution, I feel it's a lot more convoluted than it needs to be though

ahmed-bhs commented 6 months ago

@KDederichs could you provide an example for tow chained filter that one depend on the other ?

KDederichs commented 6 months ago

Not sure what you mean? If it's form fields that change based on the previous one look at the comment I posted. If it's for filters (like easy admin filters) no clue, never looked into how you'd do it there.