coosos/tag-bundle

Symfony TagBundle

安装: 427

依赖者: 0

建议者: 0

安全: 0

星星: 2

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

1.0.5 2018-03-05 21:55 UTC

This package is auto-updated.

Last update: 2024-09-19 11:02:24 UTC


README

SensioLabsInsight

TagBundle 是基于 Grafikart 视频教程 创建的扩展包。

要求

安装

步骤 1:下载扩展包

打开命令行,进入项目目录,执行以下命令以下载此扩展包的最新稳定版本

$ composer require coosos/tag-bundle

如果您的系统中已安装 composer,则使用此命令。

步骤 2:启用扩展包

然后,通过在项目的 app/AppKernel.php 文件中添加以下行来启用扩展包

// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Coosos\TagBundle\CoososTagBundle(),
        );
        // ...
    }
    // ...
}

步骤 3:在数据库中插入标签实体

使用此命令在数据库中插入标签实体

$ php bin/console doctrine:schema:update -f

用法

实体中的标签字段

namespace AppBundle\Entity;

use Coosos\TagBundle\Model\Taggable\TaggableTrait;

class Actuality {

    use TaggableTrait;

}

表单类型

要创建标签字段,您必须使用扩展包提供的字段类型

use Coosos\TagBundle\Form\Type\TagsType;
...
$builder->add("tags", TagsType::class);

选项

配置列表
用法
$builder->add("tags", TagsType::class, [
    ...,
    "coosos_tag_auto_complete"  => false,
    "coosos_tag_persist_new"    => false,
    "coosos_tag_category"       => "House"
]);

路由

您必须包含指向扩展包控制器的路由

# app/config/routing.yml

tag:
    resource: "@CoososTagBundle/Controller/"
    type: annotation

表单主题

您必须在项目中包含 jQuery tagEditor

twig:
    form_themes:
        - "CoososTagBundle:Form:fields.html.twig"
自动完成

自动完成使用 jQuery UI Autocomplete