lla/autocomplete-form-bundle

扩展Doctrine实体表单类型,通过表单事件和自定义实体加载器支持自动完成功能,作为'autocomplete'表单类型公开

安装: 146

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

1.1.2 2018-10-21 16:23 UTC

This package is auto-updated.

Last update: 2024-09-24 15:45:47 UTC


README

步骤 1:下载Bundle

打开命令行,进入项目目录,然后执行以下命令以下载此Bundle的最新稳定版本

$ composer require lla/autocomplete-form-bundle "~1"

此命令要求您全局安装了Composer,具体请参阅Composer文档中的安装章节

步骤 2:启用Bundle

然后,将Bundle添加到项目app/AppKernel.php文件中注册的Bundle列表中,以启用该Bundle

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new LLA\AutocompleteFormBundle\LLAAutocompleteFormBundle(),
        );

        // ...
    }

    // ...
}

步骤 3:使用表单类型

您可以使用表单作为普通表单使用。请参阅表单组件

<?php
// src/AppBundle/Controller/TestController.php

// ...
class TestController extends Controller
{
    public function indexAction()
    {
        // ...
        $form = $this->createForm('form_name', 'autocomplete', array(
            'class' => 'AppBundle:YourEntity',
            'max_result' => 10, // Initial options length
            'query_builder' => function(EntityRepository $repo) {
                return $repo->createQueryBuilder();
            }
        ));