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

Filters throw exception on transitive association field in field configuration #6428

Open
ServerExe opened this issue Aug 30, 2024 · 0 comments

Comments

@ServerExe
Copy link

ServerExe commented Aug 30, 2024

Describe the bug
I have 3 entities:

  • Talk (Represents a expert talk (webinar) where normal users can participate in video calls)
  • Expert (Represents the expert holding the webinar and presenting the course in the call)
  • TalkSubscription (Represents participations to a talk with the logged in user IDs)

Relations are as follows:

  • Talk < OneToMany > TalkSubscription (1 talk can have multiple subscriptions. But 1 subscription can only have 1 talk)
  • Talk < ManyToOne > Expert (1 talk can only have 1 expert. But 1 expert can have multiple talks)

I am on the crud controller of TalkSubscription and I want to display 2 AssociationField columns:

  • I want to show the associated talk: TalkSubscription -> Talk
  • I want to show the talk's associated expert: TalkSubscription -> Talk -> Expert (Transitive relation)

I made it by configuring the fields as following:

public function configureFields(string $pageName): iterable
{
    return match ($pageName) {
        Crud::PAGE_INDEX, Crud::PAGE_DETAIL => [
            IdField::new('ssoUserId')->setFormType(UuidType::class),
            AssociationField::new('talk'),
            // Seems like the the controller explicitly needs to be set for the transitive relation. 
            // Otherwise, exception occurs
            AssociationField::new('talk.expert')->setCrudController(ExpertCrudController::class),
        ],
        default => []
    };
}

This works fine. But as soon as I open filters, I get this exception:

Symfony\Component\PropertyAccess\PropertyAccessor::getValue(): Argument #1 ($objectOrArray) must be of type object|array, null given, called in /var/www/web-backoffice-expert-talk/vendor/easycorp/easyadmin-bundle/src/Field/Configurator/AssociationConfigurator.php on line 123

This is my filter setup. Nothing special at the moment:

public function configureFilters(Filters $filters): Filters
{
    return $filters->add(TextFilter::new('ssoUserId'));
}

Only when removing the transitive AssociationField::new('talk.expert') field from my field configuration, the filter is working.

(OPTIONAL) Additional context
This is the AJAX response (StatusCode 500) from the filters:

image

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

No branches or pull requests

1 participant