Skip to content

AssociationField::setQueryBuilder() does not behave as documented #5081

@victortodoran

Description

@victortodoran

Describe the bug
\EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField::setQueryBuilder() does not behave as documented docs.

Firstly the contract only accepts Closures now.
Secondly, despite what is documented, the Closure is expected to configure the implicitly passed query builder (infered from here)

So it seems that we have two options:

  1. Configure the QueryBuilder that is implictly passed to the closure provided to setQueryBuilder()
  2. Configure the query builder like this $someAssociationField->setFormTypeOption('query_builder', $someQueryBuilder);

To Reproduce

  • Easy Admin Bundle 4.0.6
  • Create an Entity, a Crud Controller and a form with an association field.
  • Try to use AssociationField::setQueryBuilder() as documented

(OPTIONAL) Additional context

I can create a PR to update the docs if you want me too, I just need to know which of the options is the desired public contract.

Cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions