ralphy
ralphy

Reputation: 99

radio button can't be entered into the database

Here is my view:

<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>

If I select any of the two, it will be entered in the database and it will be saved as a default value. I just can't do it. How can I?

Upvotes: 0

Views: 716

Answers (1)

rinat.io
rinat.io

Reputation: 3188

Keep it simple, try CActiveRecord::radioButtonList:

echo $form->radioButtonList($model, 'is_scholar', array(
    'yes' => 'Yes',
    'no' => 'No'
), array('separator' => '<br>'));

or if it's boolean column:

echo $form->radioButtonList($model, 'is_scholar', array(
    1 => 'Yes',
    0 => 'No'
), array('separator' => '<br>'));

Upvotes: 1

Related Questions