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

boolean fields are rendered without form-switch class on "add new" action #6554

Open
pfpro opened this issue Nov 20, 2024 · 5 comments
Open

Comments

@pfpro
Copy link
Contributor

pfpro commented Nov 20, 2024

on the "add new" action, boolean fields are now rendered without the form-switch class. only normal checkboxes are displayed.

image

Does anyone have a similar problem?

@bytes-commerce
Copy link
Contributor

Yes, I have the same problem on the latest version of EasyAdmin. I've also attempted to run php bin/console asset:install again to fix other issues, but this prevails with me.

@bytes-commerce
Copy link
Contributor

@javiereguiluz just a heads up, as this prevails currently in our installations. Do you have an idea? 🤔

@kadiiski
Copy link

kadiiski commented Dec 9, 2024

Hey, found the problem, it's in easyadmin-bundle/src/Field/Configurator/BooleanConfigurator.php

// this happens when processing fields not for a specific entity (e.g. when
// rendering the filters from the 'index' page)
if (null === $entityDto->getPrimaryKeyValue()) {
    $field->setCustomOption(BooleanField::OPTION_RENDER_AS_SWITCH, false);
    return;
}

This is what breaks it. Just updated and saw it happening. The problem is the specific check for getPrimaryKeyValue.
I tested by commenting it and it works, doesn't break the filters or anything else I saw.

My problem is when the entity is part of a collection in another entity.

The fix is easy but I'm not sure why was this piece of code added.

@pfpro
Copy link
Contributor Author

pfpro commented Dec 13, 2024

also see #6647

@kadiiski
Copy link

@pfpro yeah, same issue, indeed. 👍

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

3 participants