It can be useful when you need check other fields in voter for example.
Imagine users crud and disabled field in user entity.
It is weird to allow disable yourself, so better to hide that field for yourself entity.
Currently I inject AdminContextProvider and get current entity via AdminContext, but it is not possible to do it for index where ajax boolean switches (so I just disabled them all on index).
Also maybe add some generic displayIf method for field with callback. Maybe with entity parameter (if adding property is not preferably)
Something like
Field::new('disabled')->displayIf(fn ($field, $entity) => $entity->getId() !== $this->getUser()->getId());
It can be useful when you need check other fields in voter for example.
Imagine users crud and
disabledfield in user entity.It is weird to allow disable yourself, so better to hide that field for yourself entity.
Currently I inject
AdminContextProviderand get current entity viaAdminContext, but it is not possible to do it for index where ajax boolean switches (so I just disabled them all on index).Also maybe add some generic
displayIfmethod for field with callback. Maybe with entity parameter (if adding property is not preferably)Something like