1

Possible Duplicate:
Yii CHtml::radioButtonList - CSS to align horizontally

Am new to yii framework and the doubt might be silly!

I want to write a radio button code with its label next to it!

My code is as follows

<div class="column">
<?php echo $form->radioButton($model,'radio',false); ?>
<?php echo $form->error($model,'radio'); ?>
</div>

<div class="row">
<?php echo $form->labelEx($model,'I need a room'); ?>
</div>

But it doesnt look nice! Is there any better way of doing this?

1
  • please accept an answer(can be your own) and let this question be resolved, unless you wanna wait for better solutions
    – bool.dev
    Jun 20, 2012 at 4:02

2 Answers 2

3

I got the code online! Sharing it of that it can be useful for someone in future

<?php echo  $form->radioButtonList($model,'radio',array('m'=>'male','f'=>'female'),array('separator'=>'', 'labelOptions'=>array('style'=>'display:inline'))); ?>
1

The following code will create a label for the radiobutton created with the 'radio' attribute. Place this code after the 'echo $form->radiob.....'

<?php echo CHtml::activeLabel($model, 'radio', array('label' => 'My Label', 'style'=>'display:inline')); ?>

Use the display:inline or add a css class to get the label exactly where you want.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.