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

Passing EntityDto to AssociationField::OPTION_QUERY_BUILDER_CALLABLE #6180

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from

Conversation

BrunoJunior
Copy link

If I want to do something like that, I can't :

return [
            TextField::new('candidate', new TranslatableMessage('admin.candidate.label'))
                ->setDisabled(),
            TextField::new('referential', new TranslatableMessage('admin.referential.label'))
                ->setDisabled(),
            DateTimeField::new('createdAt', new TranslatableMessage('admin.experience_recognition.created_at'))
                ->onlyOnIndex(),
            EnumField::new('status', new TranslatableMessage('admin.experience_recognition.status'))
                ->setBadgeRender(new ERStatusBadgeRender('enum.er_status'))
                ->onlyOnIndex(),
            TextField::new('establishment', new TranslatableMessage('admin.establishment.label'))
                ->setDisabled(),
            AssociationField::new('accompanist', new TranslatableMessage('admin.candidate.accompanist'))
                ->onlyOnForms()
                ->setQueryBuilder(
                    fn(QueryBuilder $qb) => $this->userRepository->userWithRoleOfTheEstablishmentQuery(
                        User::ROLE_ACCOMPANIST,
                        $establishment
                    )
                ),
        ];

I would like to filter data depending on the linked establishment, with my PR we will be able to do that :

            AssociationField::new('accompanist', new TranslatableMessage('admin.candidate.accompanist'))
                ->onlyOnForms()
                ->setQueryBuilder(
                    fn(QueryBuilder $qb, EntityDto $entityDto) => $this->userRepository->userWithRoleOfTheEstablishmentQuery(
                        User::ROLE_ACCOMPANIST,
                        $entityDto->getInstance()->getEstablishment(),
                    )
                )

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 this pull request may close these issues.

1 participant