I use these data to fill the select2 kartik combobox, this is my yii2 code,
echo \kartik\widgets\Select2::widget([
'attribute' => 'pembuatSoal_id',
'model' => $model,
'data' => array_merge(["" => ""], \yii\helpers\ArrayHelper::map(\app\models\ViewUsernameGuru::find()->all(), "uname", "nama")),
'options' => ['placeholder' => 'Pilih Guru...', 'id' => 'guru-id', 'class' => "form-control"],
'pluginOptions' => [
'allowClear' => true,
'theme' => \kartik\widgets\Select2::THEME_BOOTSTRAP
],
]);
uname field as the value of the select2 and nama as the display value. but the result is like this:
But when The value of uname field is number, select2 automaticly change with the array index of select2 items.
Hope some body give me the solve.
Thanks.