EasyCorp / EasyCorp/EasyAdminBundle
Add "entity" property to FieldDto or "displayIf" method
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 4.3k
- Forks
- 1.1k
- Avg merge
- 8d 2h
- Merged PRs (30d)
- 11
Description
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());
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names FieldDto, Field::new(), displayIf, AdminContextProvider, and AdminContext. Start by tracing how field visibility and AJAX boolean switches are handled, then clarify whether the project wants an entity property or a callback API. Done means an agreed entity-aware field visibility behavior is implemented and verified for the index case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, symfony
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100