letsdecode
(Yii Devils)
1
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
mdomba
(Maurizio Domba Cerin)
2
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
$model->feedback_time='1';
asifa
(Kaziasifa)
3
Hi,
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">
<?php echo $form->labelEx($model,'newsletter');?>
<?php echo $form->radioButtonList($model,'newsletter',array('0'=>"Yes",'1'=>"No")); ?>
<?php echo $form->error($model,‘newsletter’); ?>
</div>
Thanks,
mdomba
(Maurizio Domba Cerin)
4
you posted the view code… what is your code in the controller? Where how and to what value you set $model->newsletter?
itmagetan
(Itmagetan)
5
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',
'0'=>'0',
'1'=>'1',
'2'=>'2',
'3'=>'3',
),array(
'separator'=>' ',
'labelOptions'=>array('style'=>'display: inline; margin-right: 10px; font-weight: normal;'),
)); ?>
Thanks.
jacmoe
(Jacob Moena)
6
[color="#2F4F4F"] /* moved to Yii 1.1 forum */[/color]