EasyCorp / EasyAdminBundle

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

allow dynamically generated forms #6286

Open wizhippo opened 2 weeks ago

wizhippo commented 2 weeks ago

Currently a form is always saved if submitted regardless if a ['ea']['newForm']['btn'] button was pressed

I propose to not process and save the form unless a valid button is pressed.

This will allow dynamically generate forms to work correctly so the ajax call can retrieve the updated dom without saving first.

Example of how to use this feature Following the symfony documentation create a new form type that has a field that is added if another field such as a select has a specific value.

Create a FormField using this new formtype and the supporting javascript to submit and retrieve the html for the dynamic field using the example documentation as a guide.

If the proposed behavior is added, then this will work as expected, as the request will not cause the entity to be saved without a correct button present.