wdmg/yii2-tagsinput

Bootstrap3 tags input widget for Yii2

Installs: 2 454

Dependents: 4

Suggesters: 0

Security: 0

Stars: 3

Watchers: 2

Forks: 0

Open Issues: 1

Type:yii2-extension

1.0.4 2020-03-31 23:19 UTC

This package is auto-updated.

Last update: 2024-11-04 21:27:00 UTC


README

Yii2 Downloads Packagist Version Progress GitHub license

Yii2 TagsInput

Tags input widget for Yii2

Requirements

Installation

To install the widget, run the following command in the console:

$ composer require "wdmg/yii2-tagsinput"

Usage

Example of standalone widget:

<?php

use wdmg\widgets\TagsInput;
...

echo TagsInput::widget([
    'model' => $model,
    'attribute' => 'post_tags',
    'options' => [
        'class' => 'form-control'
    ],
    'pluginOptions' => [
        'minInput' => 2,
        'maxTags' => 100
    ]
]);

?>

Example of use with ActiveForm:

<?php

use wdmg\widgets\TagsInput;
...

$form = ActiveForm::begin();
...

echo $form->field($model, 'tags')->widget(TagsInput::class, [
    'options' => [
        'id' => 'post-tags',
        'class' => 'form-control',
        'placeholder' => 'Type your tags here...'
    ],
    'pluginOptions' => [
        'autocomplete' => '//example.com/api/',
        'format' => 'json',
        'minInput' => 2,
        'maxTags' => 100
    ]
]);
...

ActiveForm::end();

?>

Options

TagsInput extends InputWidget so you can use any options available for this widget. In addition, you can use these custom options if necessary:

Status and version [ready to use]

  • v.1.0.4 - Fixed widget ID and init after Pjax reloading
  • v.1.0.3 - Up to date dependencies
  • v.1.0.2 - Fixed deprecated class declaration and added README.md