以下是我的观点:
<td><?php echo $form->labelEx($model,'Is Scholarship?'). $model->is_scholar;?></td>
<td><?php echo Chtml::radioButton($model->is_scholar,'',array('separator'=>'<br/>','class'=>'e'.$arrMF[8],'disabled'=>$isVerify,'id'=>'scholaryes','value'=>'Yes','onclick'=>'$("#scholar").show();$("#scholarno").removeAttr("checked");'));?>Yes<br/>
<?php echo Chtml::radioButton($model->is_scholar,'',array('separator'=>'<br/>','class'=>'e'.$arrMF[8],'disabled'=>$isVerify,'id'=>'scholarno','value'=>'No','onclick'=>'$("#scholar").hide();$("#scholaryes").removeAttr("checked");'));?>No</td>
<td><?php echo $form->error($model,'is_scholar');?></td>
如果我选择其中任何一个,它将被输入数据库并将保存为默认值。我不能这样做。我怎么能?
答案 0 :(得分:1)
保持简单,请尝试CActiveRecord::radioButtonList:
echo $form->radioButtonList($model, 'is_scholar', array(
'yes' => 'Yes',
'no' => 'No'
), array('separator' => '<br>'));
或者如果它是布尔列:
echo $form->radioButtonList($model, 'is_scholar', array(
1 => 'Yes',
0 => 'No'
), array('separator' => '<br>'));