kartik select2 load initial data to select before search ajax code example
Example: 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',