kartik select2 example
Example 1: kartik select2
$form->field($model, 'attribute')->widget(\kartik\select2\Select2::classname(), [
'data' => \yii\helpers\ArrayHelper::map(Model::find()->all(), 'id', 'username'),
'options' => ['placeholder' => 'Tanlang', 'multiple' => false, 'required' => true],
'theme' => \kartik\select2\Select2::THEME_KRAJEE,
'size' => 'xs',
Example 2: select2 yii2
$ php composer.phar require kartik-v/yii2-widget-select2 "@dev"