php - how to add empty field to activeDropDownList yii2? -


i have drop down list using arrayhelper::map below code:

<?= html::activedropdownlist($model2, 'expert_id',        arrayhelper::map(experts::find()->all(), 'username', 'username')) ?>

that works correctly want add empty fields or other favorite fields ... how can that?

try use array merge

 <?= html::activedropdownlist($model2, 'expert_id',   array_merge(array('val1'=>'val1'), arrayhelper::map(experts::find()->all(), 'username', 'username'))) ?> 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -