Yii2 DropDownList syntax
echo $form->field($model, 'name_field')->dropDownList( [items], [options] );
DropDownList with model data
Using below code snippet you can display the database table column’s data in the dropdownList via modal.
//use app\models\Country; $countries=Country::find()->all(); //use yii\helpers\ArrayHelper; $listData=ArrayHelper::map($countries,'code','name'); echo $form->field($model, 'name')->dropDownList( $listData, ['prompt'=>'Select...'] );