EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Default field for boolean property doesn't load field-boolean.js

Open filipchuk opened this issue 1 year ago • 4 comments

Entity has a boolean property, e.g. "enabled" On the index page when do not use "configureFields" method or use yield Field::new('enabled') it renders switch but it doesn't work correctly because there is no saving request on the switch's change. This is because asset file field-boolean.js is not in the js assets list in this case and not loaded

If explicity set yield BooleanField::new('enabled'); it works good, the asset filefield-boolean.js loaded as well

SF verion 6.4 EA version 4.1

filipchuk avatar May 12 '24 15:05 filipchuk

It is because assets includes in BooleanField::new explicitly. https://github.com/EasyCorp/EasyAdminBundle/blob/6248349de0e108640b78bef70656db6f35f7386c/src/Field/BooleanField.php#L38 Field::new magic does not work there

zorn-v avatar May 13 '24 18:05 zorn-v

I stumbled over it years ago, and decided to explicitly create not standard fields.

zorn-v avatar May 13 '24 18:05 zorn-v

Just don't quite understand why the js file can't be loaded by default when Field::new rendered as boolean switch. For simple CRUD controllers this will avoid having to manually specify form fields and update it each time the source table changed Besides it took much time to In addition, it is not intuitive, because you expect that the field should work, but it does not Anyway, thank you for the response. At least I know there it's not a bug but a feature :)

filipchuk avatar May 15 '24 05:05 filipchuk

At least I know there it's not a bug but a feature :)

I did not not say that. I also consider it as bug, but lazy to find a way to fix it )

zorn-v avatar May 15 '24 09:05 zorn-v