activefield don't save the attribute shown in the dropdownlist



$carList = ArrayHelper::map(car::find()->all(),'id','car');

<?= $form->field($model, 'car')->dropDownList( $carList ) ?>


The car would be shown in the dropDownList, but the Activefield tried to save the ‘id’.


in carList array, ‘id’ are the keys and ‘car’ are the values,

so the option in select will be:

<option value="__id_value__">__car_value__</option>


Do you want car as key and value?

Thanks for answer.

I just want that the dropDownList shows the ‘bmw’, ‘mercedes’, ‘ford’, … to be selected und saved.

I have changed the order ‘car’ and ‘id’ in the map method:

$carList = ArrayHelper::map(car::find()->all(),'car','id');

the id would be showned but the car would be saved.


OK, it is:

$carList = ArrayHelper::map(car::find()->all(),'car','car');

So ‘car’ is the same for the key and the value of option tag.

It works!

Thank you very much indeed!