pff/tag-it-bundle

There is no license information available for the latest version (dev-master) of this package.

Bundle to help use the Tag It library

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

This package is not auto-updated.

Last update: 2024-04-13 11:20:28 UTC


README

Huge thanks to the Mopa Bootstrap bundle for ideas on how to handle this!

Installation

Basic setup (include tag-it as well)

{
    // ...
    "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"
        ...
    },
    // ...
}

Automatic linking to put tag-it in the right location

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

Add the form template to config.yml

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

In the template you want to use the Tag It form field in:

{% 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 %}

Usage

In your object

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

Finally to implement in your form

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