Can't understand Dropdownlist and selectedValue


(alexsultana) #1

Hello guys.

I don’t understand how dropdown list works. I want to take selected value from dropdown list.

My code looks like:

<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
   	 <?= $form->field($model1, 'test')->dropDownList($items)->label(false);?>
	
	<button>Submit</button>
	<?php ActiveForm::end() ?>

where $items =[‘A’,‘B’,‘C’…‘Z’];

And the default displayed value for this is ‘A’, i want to change this value.

I’ve tried with $model1->test, but this is not my selected value.

Thanks!