ActiveForm 的下拉菜單 dropDownList

来源:互联网 发布:手机记牌器软件 2016 编辑:程序博客网 时间:2024/05/21 06:57

一句話總結

就是dropDownList裏面放入需要的數組 和默認項prompt

<?= $form->field($model,'status')->dropDownList([    'active'=>'Active','inactive'=>'Inactive',    'prompt'=>'Select Status'])->label(false);

附:
這裏面的數組是常量,可以數據庫查詢導入值來做。例:

<?=$form->field($model,'status')->dropDownList([    ArrayHelper::map(User::find()->all(),'status','id'),    'prompt'=>'Select Status']);