Symfony3 Tetranz/select2 - remote_route

Symfony3 Tetranz/select2 - remote_route

我正在尝试为我的项目使用 select2entity-bundle 来实现自动完成。

使用builder时,规范如下:

$builder
   ->add('country', Select2EntityType::class, [
            'multiple' => true,
            'remote_route' => 'tetranz_test_default_countryquery',
            'class' => '\Tetranz\TestBundle\Entity\Country',
            'primary_key' => 'id',
            'text_property' => 'name',
            'minimum_input_length' => 2,
            'page_limit' => 10,
            'allow_clear' => true,
            'delay' => 250,
            'cache' => true,
            'cache_timeout' => 60000, // if 'cache' is true
            'language' => 'en',
            'placeholder' => 'Select a country',
            // 'object_manager' => $objectManager, // inject a custom object / entity manager 
        ])

'remote_route' 参数中应该指定什么? 为什么我的字段应该链接到路线?应该如何以及在何处配置此路由?它应该链接到查询吗?

感谢您的帮助!

select 需要更新要在用户键入时显示的值。它通过向您需要编写的控制器发送请求来完成此操作,该控制器收集相关值并将它们 returns 作为 json.

创建一个控制器,returns 项目列表显示在 select 中,并使用您为该控制器定义的路由名称作为 'remote_route' 参数。

返回数据的格式记录在 github https://github.com/tetranz/select2entity-bundle

的捆绑包页面的中间位置