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

Add "entity" property to FieldDto or "displayIf" method #6102

Open
zorn-v opened this issue Jan 16, 2024 · 0 comments · May be fixed by #6451
Open

Add "entity" property to FieldDto or "displayIf" method #6102

zorn-v opened this issue Jan 16, 2024 · 0 comments · May be fixed by #6451

Comments

@zorn-v
Copy link
Contributor

zorn-v commented Jan 16, 2024

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());
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

Successfully merging a pull request may close this issue.

1 participant