1. Go to this page and download the library: Download ommu/yii2-selectize 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/ */
// setup the following to get the existing data from database
$model->attribute = 'first, last';
// or if the data is an array you can preselect the tags like this
$model->attribute = implode(', ', ["first", "last"]);
echo $form->field($model, "attribute")->widget(Selectize::className(), [
'url' => '/site/search',
'pluginOptions' => [
'valueField' => 'name',
'labelField' => 'name',
'searchField' => ['name'],
'persist' => false,
'createOnBlur' => true,
'create' => true
]
]);