TagBundle is a bundle created from the Grafikart video.
- Symfony 3.0 and greater
- PHP 7.0 and greater
- jQuery tagEditor (optional)
- jQuery UI Autocomplete (optional)
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle :
$ composer require coosos/tag-bundle
This command is used if composer is installed in your system.
Then, enable the bundle by adding the following line in the app/AppKernel.php
file of your project :
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Coosos\TagBundle\CoososTagBundle(),
);
// ...
}
// ...
}
Use this command to insert tag entity in your database
$ php bin/console doctrine:schema:update -f
namespace AppBundle\Entity;
use Coosos\TagBundle\Model\Taggable\TaggableTrait;
class Actuality {
use TaggableTrait;
}
To create a field for tags, you must use a field type provided by the bundle
use Coosos\TagBundle\Form\Type\TagsType;
...
$builder->add("tags", TagsType::class);
Config name | Default value | Values | Description |
---|---|---|---|
coosos_tag_auto_complete | true | true | false | If you want to use auto completion |
coosos_tag_persist_new | true | true | false | If you want the tags not exist is created |
coosos_tag_category | "default" | string | If you want to separate tags in different categories |
$builder->add("tags", TagsType::class, [
...,
"coosos_tag_auto_complete" => false,
"coosos_tag_persist_new" => false,
"coosos_tag_category" => "House"
]);
You must include the route to the bundle controller
# app/config/routing.yml
tag:
resource: "@CoososTagBundle/Controller/"
type: annotation
You must have jQuery tagEditor included in your project
twig:
form_themes:
- "CoososTagBundle:Form:fields.html.twig"
The auto completion uses the library jQuery UI Autocomplete