There seem to be many good answers to this question. Therefore, I will try to give a detailed answer
active form and hard-coded data
<?php echo $form->field($model, 'name')->dropDownList(['1' => 'Yes', '0' => 'No'],['prompt'=>'Select Option']); ?>
or
<?php $a= ['1' => 'Yes', '0' => 'No']; echo $form->field($model, 'name')->dropDownList($a,['prompt'=>'Select Option']); ?>
active form and data from table db
we're going to use an ArrayHelper, so first add it to the namespace
<?php use yii\helpers\ArrayHelper; ?>
ArrayHelper uses many functions that can be used to process map () arrays - this is the one we will use here this function helps to make a map (key-value pairs) from a multidimensional array or an array of objects.
<?php echo $form->field($model, 'name')->dropDownList(ArrayHelper::map(User::find()->all(),'id','username'),['prompt'=>'Select User']); ?>
not part of the active form
<?php echo Html::activeDropDownList($model, 'filed_name',['1' => 'Yes', '0' => 'No']) ; ?>
or
<?php $a= ['1' => 'Yes', '0' => 'No']; echo Html::activeDropDownList($model, 'filed_name',$a) ; ?>
not the active form, but the data from the db table
<?php echo Html::activeDropDownList($model, 'filed_name',ArrayHelper::map(User::find()->all(),'id','username'),['prompt'=>'Select User']); ?>