Answer the question
In order to leave comments, you need to log in
How to display stored values in select2?
I use plugins from Kartik DepDrop and Select2
In
the second select, I select several values \u200b\u200bat once (multiple), I get an array
Here is my form
<?php $form = ActiveForm::begin(['id' => 'games-form']);?>
<?= $form->field($model, 'id')->label('')->dropDownList(ArrayHelper::map(Platforms::find()->all(), 'id', 'name'), ['id'=>'cat-id', 'prompt' => '- ' . Yii::t('main', 'Select platform') . ' -']) ?>
<?= $form->field($model, 'game_id')->label('')->widget(DepDrop::classname(), [
'type' => DepDrop::TYPE_SELECT2,
'options' => ['multiple' => true],
'pluginOptions'=>[
'depends'=>['cat-id'],
'placeholder'=>'- ' . Yii::t('main', 'Select games') . ' -',
'url'=>Url::to(['/user/default/getgame'])
]
])
?>
<?= Html::submitButton(Yii::t('main', 'Save'), ['class' => 'btn btn-primary'])?>
<?php ActiveForm::end(); ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question