pff/tag-it-bundle

该包最新版本(dev-master)没有提供许可信息。

帮助使用 Tag It 库的捆绑包

dev-master 2012-12-14 16:04 UTC

This package is not auto-updated.

Last update: 2024-09-28 13:15:18 UTC


README

非常感谢 Mopa Bootstrap bundle,它提供了如何处理这些想法的灵感!

安装

基本设置(包括 tag-it)

{
    // ...
    "repositories": [
        {
            "type":"package",
            "package":{
                "name":"aehlke/tag-it",
                "version":"dev-master",
                "source":{

                    "url":"git://github.com/aehlke/tag-it.git",
                    "type":"git",
                    "reference":"master"
                }
            }
        }
    ],
    "require": {
        // all your existing requires
        ...
        "pff/tag-it-bundle": "dev-master",
        "aehlke/tag-it": "dev-master"
        ...
    },
    // ...
}

自动链接以将 tag-it 放在正确位置

{
    // ...
    "scripts": {
        "post-install-cmd": [
            "Pff\\Bundle\\TagItBundle\\Composer\\ScriptHandler::postInstallSymlinkTagIt"
        ],
        "post-update-cmd": [
            "Pff\\Bundle\\TagItBundle\\Composer\\ScriptHandler::postInstallSymlinkTagIt"
        ]
    }
    // ...
}

将表单模板添加到 config.yml

twig:
    form:
        resources:
            - 'PffTagItBundle:Form:fields.html.twig'

在您想要使用 Tag It 表单字段的模板中

{% block javascripts %}
    {{ parent() }}
    {% javascripts '@PffTagItBundle/Resources/tag-it/js/*.js' %}
        <script type="text/javascript" src="{{ asset_url }}"></script>
    {% endjavascripts %}
{% endblock javascripts %}
{% block stylesheets %}
    {{ parent() }}
    {% stylesheets '@PffTagItBundle/Resources/css/jquery.tagit.css' output="css/compiled/tag-it.css" %}
        <link rel="stylesheet" type="text/css" href="{{ asset_url }}" />
    {% endstylesheets %}
{% endblock stylesheets %}

用法

在您的对象中

/**
 * @ORM\Column(type="text", nullable=true)
 */
protected $tags;

最后在您的表单中实现

->add('tags', 'tagit', array(
    'required' => false,
    'label' => 'Tags',
    'data_path' => $this->container->get('router')->generate('my_tag_list'),
))