PHP code example of efureev / yii2-tagsinput

1. Go to this page and download the library: Download efureev/yii2-tagsinput library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

efureev / yii2-tagsinput example snippets


<?= $form->field($model, 'users', ['options' => [
    'class' => 'form-group',
]])->widget(
    \efureev\tagsinput\TagsInput::className(),
    [
        'preJS' => 'var users = new Bloodhound({
            datumTokenizer: Bloodhound.tokenizers.obj.whitespace("title"),
            queryTokenizer: Bloodhound.tokenizers.whitespace,
            prefetch : { url : "/users", cache : false,
                filter: function (list) {
                    return $.map(list, function (user) {
                        return {text: user.name};
                    });
                }
            }
        });',
        'clientOptions' => [
            'typeaheadjs' => [
                'displayKey' => 'text',
                'trimValue'  => true,
                'valueKey'   => 'text',
                'name'       => 'users',
                'source'     => new \yii\web\JsExpression('users.ttAdapter()')
            ]
        ]
    ]
);