How to set a specific radio buttion option selected by default using CActiveForm.radioButtonList()

Hi all,

i am using radioButtonList to list a group of options by using the following code.

<?php echo $form->radioButtonList($model,‘feedback_time’, array(‘0’=>'option1 ', ‘1’=>'option 2 ', ‘2’=>'option3 ')); ?>

The problem is by default none of the option is selected by default. when I see the generated html source code, it doesn’t show

checked="checked" for any of the radio button options. Could you pls tell me how to achieve that using yii methods.

waiting for the reply…!

-Big O

just set the $model->feedback_time to the desired value…

For example if you want selected the option ‘option 2’, as per your example above set



I tried using your example in my code but it is giving me errors,can u plz specify how to use it.My code is below

<div class="row">

	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'newsletter');?&gt;

	&lt;?php echo &#036;form-&gt;radioButtonList(&#036;model,'newsletter',array('0'=&gt;&quot;Yes&quot;,'1'=&gt;&quot;No&quot;)); ?&gt;

<?php echo $form->error($model,‘newsletter’); ?>



you posted the view code… what is your code in the controller? Where how and to what value you set $model->newsletter?

Hi mdomba, i would like to know how to make a radioButton option visible/hidden based on a value in other table.

Below is my code:

		<?php echo $form->radioButtonList($model,'nilai',array(

                            'tidak_hadir'=>'Tidak Hadir',







                        'labelOptions'=>array('style'=>'display: inline; margin-right: 10px; font-weight: normal;'),

                )); ?>


[color="#2F4F4F"] /* moved to Yii 1.1 forum */[/color]