Hello,
i use the Select2 Widget by Kartik-V into an ActiveForm and my Debugger tells me everytime, that the selected value is null. Also into the DB will not saved the country-ID. Why?
the form:
<?= $form->field($model,'country')->widget(Select2::className(),[
'language' => Yii::$app->language,
'data' => Countries::get4Dropdown(),
'options' => [ 'placeholder' => Yii::t('app','Land auswählen')],
'pluginOptions' => [ 'allowClear' => true ],
]) ?>
Countries::get4Dropdown:
public static function get4Dropdown() {
return ArrayHelper::map(self::find()->orderBy("name")->asArray()->all(),'id','name');
}
Debugger (from the Form-Class):
$this={common\models\ContactsForm}
id=1
first_name="Tester"
last_name="Test"
...
country=null,
...
What’s wrong with the Select2-Widget?
Thanks,
Stefan