I am returning cat_id value by GET in url to say that my dropdown list, which Item must be select. But it's not working.
<?= $form->field($model, 'cat_id')->dropDownList(
ArrayHelper::map(DeviceCats::find()
->where(['is_deleted' => 'no'])->all(),'id','title')
,['options' => [$_GET['cat_id'] => ['selected'=>true]]
, 'prompt' => ' -- Select Category --']) ?>
Finally solved with an unbelievable change. Just changed the first letter of selected to capital ('selected' should be 'Selected'). Here is the code:
<?= $form->field($model, 'cat_id')->dropDownList(
ArrayHelper::map(DeviceCats::find()
->where(['is_deleted' => 'no'])->all(),'id','title')
,['options' => [$_GET['cat_id'] => ['Selected'=>'selected']]
, 'prompt' => ' -- Select Category --']) ?>