foreach($add_details_arr as $key=>$val1){
if($val1 == '1'){
$ck1= "checked=>'checked'";
}else{
$ck1= '';
} if($val1 == '2'){
$ck2= "checked=>'checked'";
}else{
$ck2= '';
}
}
在我看来
<?php echo CHtml::activecheckBox($model,'setting[0]',array('value'=>'1','uncheckValue'=>null, 'class'=>'radio',checked=>$ck1)); ?>
<?php echo CHtml::activecheckBox($model,'setting[1]',array('value'=>'2','uncheckValue'=>null, 'class'=>'radio',checked=>$ck2)); ?>
答案 0 :(得分:0)
试试这个 -
foreach($add_details_arr as $key=>$val1){
if($val1 == '1'){
$ck1 = 'checked';
}else{
$ck1= '';
} if($val1 == '2'){
$ck2= 'checked';
}else{
$ck2= '';
}
echo CHtml::activecheckBox($model,'setting[0]',array('value'=>'1','uncheckValue'=>null, 'class'=>'radio',checked=>$ck1));
echo CHtml::activecheckBox($model,'setting[1]',array('value'=>'2','uncheckValue'=>null, 'class'=>'radio',checked=>$ck2));
}