EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Toggle switch on/off not working on no-persisted fields

Open OCoulonAckwa opened this issue 8 months ago • 0 comments

EA 4.9.4, Symfony 6.4

Since EA 4.9.4, Toggle switch on/off not working on no-persisted fields

Getter and setter on the non persisted field are present in the entity. I explicitely reference it as boolean in the CrudController : BooleanField::new('notDeleted', 'Active');

Toggle switch raise exception The field xxx is not allowed to be modified

https://github.com/EasyCorp/EasyAdminBundle/commit/b90a94cabe4992e6c03ad48dc4072343abdfb82b

Method ajaxEdit() from AbstractCrudController.php call $field = $entityDto->getFields()->getByProperty($propertyName); witch return null on a non persisted field.

$field = $entityDto->getFields()->getByProperty($propertyName);
        if (null === $field || true === $field->getFormTypeOption('disabled')) {
            throw new AccessDeniedException(sprintf('The field "%s" is not allowed to be modified.', $propertyName));
        }

With throw exception commented, all work fine : Toggle button works and new value is set in database thank to the setter.

Thank's

OCoulonAckwa avatar Jun 19 '24 08:06 OCoulonAckwa