多年级勾选
function updatenews(){
$id=I("id");
$data=M("series")->find($id);
//调取年级
$grade=M('activity_grade')->where("1")->order("id asc")->select();
$this->assign("grade",$grade);
$activity_inner= M('activity_grade_map')->field("grade_id")->where(array('activity_id' => $id,'type'=>'2'))->select();
foreach($activity_inner as $key=>$value) {
$grades[] = $value["grade_id"];
}
$this->assign("grades",$grades);
$this->assign("data",$data);
$this->display();
}
<div class="control-group">
<label class="control-label">{:L('适合年级')}</label>
<div class="controls">
<label>
<volist name="grade" id="item" key="key" >
<input name="grade_id[]" type="checkbox" id="grade_id[]" value="{$item.id}" <?php if(in_array($item['id'], $grades)) { echo "checked";} ?> >
{$item.name}
</volist>
</label>
</div>
</div>