Problems with Registration Form

On form submission female gender is saved in table but when male is selected it’s not saved

<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')); ?>


email and password are auto-filled on page load. email is filled with ‘admin’ and password is filled with 5 asterisks

<div class="frmFields">

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

		<?php echo $form->emailField($model,'email', array("style"=>"border:1px solid #DCDCDD")); ?>

		<?php echo $form->error($model,'email'); ?>


	<div class="frmFields">

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

		<?php echo $form->passwordField($model,'password', array("style"=>"border:1px solid #DCDCDD")); ?>

		<?php echo $form->error($model,'password'); ?>


Have a look at this topic

Radio Button

Dear Shaani

My doubt is whether we can create a form element for particular attribute more than once.

If the attribute is declared twice and when the form is posted the values collected from the first form

element is replaced by second one. That may be the reason that it works only for female in your scenario.

Here the easiest option may be radioButtonList.

<?php echo $form->radioButtonList($model, 'gender',array(1=>'male',2=>'female'));


<?php echo $form->radioButtonList($model, 'gender',array('male'=>'male','female'=>'female'));

It doesn’t work as desired. It’s inserting <br> tags.

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


<span id="Userregistration_gender"><input type="radio" name="Userregistration[gender]" id="Userregistration_gender_0" value="Male"> <label for="Userregistration_gender_0">Male</label><br>

<input type="radio" name="Userregistration[gender]" id="Userregistration_gender_1" value="Female"> <label for="Userregistration_gender_1">Female</label></span>

Desired output is

<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

It inserts <br> tags

Can you please try this?

<?php echo $form->radioButtonList($model, 'gender',array('male'=>'male','female'=>'female'),array('separator=>''));

can I have the male radio button checked on page load ? also, why is the email field filled with admin and password field is filled with asterisk on page load ?

Dear Friend

Regarding "male" radio button getting checked on page load, my solution is to explicitly

declare the following in the AR model.

public $gender="male";

If you have found a better solution, kindly post that one.

Regarding problem of email and password field with some default values on page load , I want to know how you have assigned $model in controller method. Would you please post the code in the controller method?.