[英]Sonata ModelAutocompleteType Query/Callback
I'd like to use something like a query_builder
for the EntityType::class
so I can only display specific results. 我想对
EntityType::class
使用诸如query_builder
之EntityType::class
所以我只能显示特定的结果。
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: 我的工作EntityType示例:
'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?
如何应用类似于ModelAutocompleteType回调的内容?
This documentation section might help you https://symfony.com/doc/master/bundles/SonataAdminBundle/reference/form_types.html use SonataAdminBundleFormTypeModelAutocompleteType. 本文档部分可能会帮助您https://symfony.com/doc/master/bundles/SonataAdminBundle/reference/form_types.html使用SonataAdminBundleFormTypeModelAutocompleteType。 As your question is hard to understand due to lack of context, you might also be interested in https://sonata-project.org/bundles/doctrine-orm-admin/master/doc/reference/filter_field_definition.html doctrine_orm_model_autocomplete.
由于缺乏上下文,您的问题难以理解,因此您可能还会对https://sonata-project.org/bundles/doctrine-orm-admin/master/doc/reference/filter_field_definition.html doctrine_orm_model_autocomplete感兴趣。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.