How to make a dropdown in yii2 using an activeform and a model? Since all the methods has changed in yii2,how it is done
Maybe I'm wrong but I think that SQL query from view is a bad idea
This is my way
In controller
$model = new SomeModel();
$items=ArrayHelper::map(TableName::find()->all(),'id','name');
return $this->render('view',['model'=>$model, 'items'=>$items])
And in View
= Html::activeDropDownList($model, 'item_id',$items) ?>
Or using ActiveForm
= $form->field($model, 'item_id')->dropDownList($items) ?>