一、控制器
1.查询出复选框中需要列出的列表
获取前一页面的url(yii2.0)
Yii::$app->request->getReferrer()
2.判断条件 需要默认显示的数据
3.使用$model->字段=array(值);
二、试图
展示数据
<?=$form->field($model,
'category_id')->label(Yii::t('app','分类'),['style'=>'font-size:14px;font-weight:
bold;'])->checkboxList($model->getCategoryIds())?>
三、模型
查出复选框列表的值
表名::find()->asArray()->all();
foreach($model
as
$row) {
$r[$row['ID']]
= $row[$this->getName()];
}
这样就可以实现 复选框默认选择值
这样就可以实现 复选框默认选择值
