boolean fields are rendered without form-switch class on "add new" action
on the "add new" action, boolean fields are now rendered without the form-switch class. only normal checkboxes are displayed.
Does anyone have a similar problem?
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.
@javiereguiluz just a heads up, as this prevails currently in our installations. Do you have an idea? :thinking:
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.
also see https://github.com/EasyCorp/EasyAdminBundle/issues/6647
@pfpro yeah, same issue, indeed. 👍