Yii2 Select2 widget
composer require rootlocal/yii2-select2
or add
"rootlocal/yii2-select2": "dev-master"
to the require section of your composer.json.
<?php
use yii\web\View;
use yii\bootstrap4\ActiveForm;
use rootlocal\widgets\select2\Select2Widget;
/**
* @var View $this
* @var ActiveForm $form
*/
?>
<?= $form->field($model, 'attribute')->widget(Select2Widget::class,['items'=> $model->getItems()]) ?>