Sonata ModelAutocompleteType Query/Callback

Viewed 1172

I'd like to use something like a query_builder for the EntityType::class so I can only display specific results.

I noticed according to the docs you can use callback but I was struggling to figure out how I'd apply this.

My working EntityType example:

'query_builder' => function (MyRepository $repository) use ($example) {
    return $repository->findByExampleBuilder($example);
}

This returns a query builder which works. How can I apply something similar to the ModelAutocompleteType callback?

1 Answers
Related