0

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?

İsmet Alkan
  • 5,361
  • 3
  • 41
  • 64
ralphy
  • 89
  • 1
  • 14

1 Answers1

1

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>'));
rinat.io
  • 3,168
  • 2
  • 21
  • 25
  • if i try that i wont be able to show and hide my div because that's the only way i can do that . – ralphy Jan 10 '13 at 18:44
  • Why? Use something like `$(':radio[name="ModelName[is_scholar]"]').change(function() { $("#scholar").toggle($(this).val()) })`. Search by [SO](http://stackoverflow.com/questions/986120/how-to-get-the-value-of-a-selected-radio-button-using-its-name-in-jquery) – rinat.io Jan 10 '13 at 21:21