'1'=>'中国',
'2'=>'日本',
'3'=>'美国',
'4'=>'德国',
Controller中的actionCreate()方法中写入
$model->fid = array(1,2);//默认选中1和2选线
$this->render('opfunction',array(
'model'=>$model,
'B'=>$showB,
));
array('separator'=>' ','labelOptions'=>array('class'=>'labelForRadio'))是要改变checkbox的显示格式,如果不改变,是竖着显示的,改变后是横排显示。如要更改的话还需要要CSS文件中的form中加入
<style type="text/css">
label .labelForRadio{display:inline-block;width:auto;float:none;}
.checkbox{display:inline-block;width:auto;float:none; width:100px;}
</style>
checkBoxList是表单里面的,使用$form->checkBoxList(的时候须在前面加上下面的widgets.TbActiveForm
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
'id'=>'plat-form-user-form',
'type'=>'horizontal',
'enableAjaxValidation'=>false,
)); ?>