Yii2 给 dropDownList 下拉框一个全部默认选择

技巧库 · echo · 于 6年前 发布 · 6231 次阅读

有两种方式:

方式一:使用 prompt

echo Html::activeDropDownList($model, 'status', ['0' => '关闭', '0' => '开启'], ['class' => 'form-control', 'prompt' => '全部']);

方式二:

echo Html::activeDropDownList($model, 'status', ['' => '全部', '0' => '关闭', '0' => '开启'], ['class' => 'form-control']);

本文由 echo 创作,采用 知识共享署名 3.0 中国大陆许可协议 进行许可。 可自由转载、引用,但需署名作者且注明文章出处。

共收到 0 条回复 技巧库
没有找到数据。
添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册