Radio Button

Hi all,

I have a form like this :

<div class="row">

<?php echo $form->labelEx($model,‘jnsKelamin’); ?>

<?php echo $form->radioButton($model,‘jnsKelamin’,array(‘value’=>‘Male’)) . ‘Male’; ?>

<?php echo $form->radioButton($model,‘jnsKelamin’,array(‘value’=>‘Female’)) . ‘Female’; ?>

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


Why if I choose Male, the value = 0,

instead female value is correct = Female ?


Any help will be highly appreciated.

why you are not using radioButtonList ???

hi, thanks for your suggestion, but after I tried radioButtonList, I was succesfully to use it, but get the result in vertical mode, how to make it appear in horizontal mode.

Here are my codes ;


		$accountStatus = array('Male'=>'Male', 'Female'=>'Female');

		echo $form->radioButtonList($model,'jnsKelamin',$accountStatus,array('separator'=>' '));


thanks anyway.

I get the same case. How to make it vertically?

Let’s discuss it here :)


This is my first post in Yii, so, hello everybody.

It’s been three days now that I’m trying to solve what “jimmi nababan” said:

I need to use RadioButton, not radioButtonList because i’m using one radiobutton option inside of an Accordion component, and the other outside, so, it can’t be a list.

I’m really worried for these, since I can’t go on with the project without this. I have read EVERYTHING I’ve find, and no solutions…

Any ideas?

Thank you!

You have to use radio button list.

If you use 2 radio button, the second (female) will override the value of the first.

Use radio button list + css for put them horizotally. Take a look at this.

P.S: welcome to the forum jdl!

Hello Zaccaria,

Thank you very much for your fast response. I think I can’t do what I want with styling. I have added an image to show what I’d like to do:



I am using the Jui Accordion Yii component, to show the rest of available radiobuttons, and the first one out of it…


I’ll try styling that way…

Thank you!

for vertically:


$accountStatus = array('Male'=>'Male', 'Female'=>'Female');

echo $form->radioButtonList($model,'jnsKelamin',$accountStatus,

array('separator'=>' ',

'labelOptions'=>array('style'=>'display:inline'), // add this code




I have 3 radiobuttons in a row. I need to decorate each of them individually. How can I do it using radiobutton list?

And why Yii inserts additional empty radiobutton inputs? I have problem with form serialization and parsing its values


1 Like

Any other responses? display:inline isn’t working for me.