radioButtonList without Label

I’m trying to generate label and 2 radio buttons like this:

<label style="color:#C29A4B; font-weight:bold;">Gender <span class="pink-color">*</span></label>

<span style="Width:20px!important;"><input type="radio" checked="checked" value="Male" name="gender" id="male"></span>Male

<span style="Width:20px!important;"><input type="radio" value="Female" name="gender" id="female"></span>Female

Using this:

<?php echo $form->labelEx($model,'gender', array("style"=>"color:#C29A4B; font-weight:bold")); ?>

		<span style="Width:20px!important;">

		<?php echo $form->radioButtonList($model, 'gender', array("value"=>"Male")); ?>


But not getting the desired output

I don’t want this generated <label for=“Userregistration_gender_0”>Male</label>

I want two radio buttons with only one checked and no labels

From the documentation: or for which the former is a wrapper

echo $form->radioButtonList($model, 'gender', array('male'=>'', 'female' => ''), array('template' => '{input}', 'style' => 'width:20px!important', 'separator' => ''));

But I don’t believe you can force the checked attribute for one of the options if the model’s attribute is not already set to true. Or you should use CHtml::radioButtonList in order to set the checked value like you want.

Where can I get the documentation for htmloptions array ? These are not listed in CActiveForm reference page .‘template’ => ‘{input}’, ‘separator’ => ‘’.

If I use CHtml::radioButtonList then I get the message gender field is empty

No, but that page refers to the second link I gave you in my last message. And there, you find $htmlOptions detail

I don’t understand. Please clarify and post your code :)

you can set a default value if you want to

echo $form->radioButtonList($model, 'gender', array('male'=>'', 'female' => ''), array('template' => '{input}', 'style' => 'width:20px!important', 'separator' => ''));

array(‘male’=>’’, ‘female’ => ‘’)


array(‘male’=>1, ‘female’ => ‘’) // select the one you wanna have as default

This is working as desired

                  <span style="Width:20px!important;">

		<?php echo $form->radioButton($model, 'gender', array('checked'=>'checked', 'value'=>'Male')); ?>


		<span style="Width:20px!important;">

		<?php echo $form->radioButton($model, 'gender', array('value'=>'Female')); ?>