Use TagType in any Symfony form:
use Nowo\TagInputBundle\Form\TagType;
use Nowo\TagInputBundle\Form\ValueFormat;
$builder->add('tags', TagType::class, [
'placeholder' => 'Add tags and press Enter',
'max_tags' => 10,
'whitelist' => ['php', 'symfony', 'twig'],
'input_class' => 'form-control',
]);The field value is an array of strings by default, for example ['php', 'symfony'].
Use value_format => ValueFormat::STRING to receive a comma-separated string instead.
The bundle registers the Twig namespace @NowoTagInputBundle/. Application files under templates/bundles/NowoTagInputBundle/ always win over the copies inside the package (TwigPathsPass adds the bundle views path after application paths so your copies are tried first).
Freeze rule: a full-file override hides vendor updates for that <subpath> until you delete or manually merge it. Prefer selecting the matching form theme via nowo_tag_input.form_theme (see CONFIGURATION.md) and only override the one theme file you customise.
Procedure
- Identify the
<subpath>from the table below (path relative tosrc/Resources/views/). - Create in your application:
templates/bundles/NowoTagInputBundle/<subpath>(same relative path and filename). - Clear the cache in dev if needed:
php bin/console cache:clear.
Example — override the default form theme:
templates/bundles/NowoTagInputBundle/Form/tag_input_theme.html.twig
Logical names look like @NowoTagInputBundle/Form/tag_input_theme.html.twig.
Overridable templates
| Subpath | Purpose |
|---|---|
Form/tag_input_theme.html.twig |
Default form theme (form_div_layout) |
Form/tag_input_theme_table.html.twig |
Table form layout |
Form/tag_input_theme_bootstrap3.html.twig |
Bootstrap 3 |
Form/tag_input_theme_bootstrap3_horizontal.html.twig |
Bootstrap 3 horizontal |
Form/tag_input_theme_bootstrap4.html.twig |
Bootstrap 4 |
Form/tag_input_theme_bootstrap4_horizontal.html.twig |
Bootstrap 4 horizontal |
Form/tag_input_theme_bootstrap5.html.twig |
Bootstrap 5 |
Form/tag_input_theme_bootstrap5_horizontal.html.twig |
Bootstrap 5 horizontal |
Form/tag_input_theme_foundation5.html.twig |
Foundation 5 |
Form/tag_input_theme_foundation6.html.twig |
Foundation 6 |
Form/tag_input_theme_tailwind2.html.twig |
Tailwind 2 |
Pick the row that matches form_theme in config/packages/nowo_tag_input.yaml (or your app twig.form_themes).
Override translation keys from your application. See Configuration — Translations.
Publish and include the bundle assets:
php bin/console assets:install public<link rel="stylesheet" href="{{ asset('tag-input.css', 'nowo_tag_input') }}">
<script src="{{ asset('tag-input.js', 'nowo_tag_input') }}"></script>The widget is <nowo-tag-input> (light DOM: native input wrapped by Tagify). Legacy [data-nowo-tag-container="1"] hosts still initialize.
value_format:array(default) orstringmax_tags: maximum number of tagswhitelist: allowed tag values (enables suggestions)pattern: regex pattern without delimitersduplicates: allow duplicate tagsdropdown_enabled: Tagify dropdown for whitelist suggestionsplaceholder: input placeholdercontainer_class,input_class: CSS classes