Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
filipchuk opened this issue May 12, 2024 · 4 comments
Open

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

filipchuk opened this issue May 12, 2024 · 4 comments

Comments

@filipchuk
Copy link

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

@zorn-v
Copy link
Contributor

zorn-v commented May 13, 2024

It is because assets includes in BooleanField::new explicitly.

->addJsFiles(Asset::fromEasyAdminAssetPackage('field-boolean.js')->onlyOnIndex())

Field::new magic does not work there

@zorn-v
Copy link
Contributor

zorn-v commented May 13, 2024

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

@filipchuk
Copy link
Author

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

@zorn-v
Copy link
Contributor

zorn-v commented May 15, 2024

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 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants