I've Been Confused With Attributesnames()

In my userRegister model I defined $password_repeat variable,along with textfields existed in the database forms the actual input form which will be used to collect user inputs from the activeForm,but when I using:

$newUser->attributes = $_POST[‘registerForm’];

I found that $attributes only contains textfields that existed in the DB which means $password_repeat is excluded from it,I do not know why my extra defined variable is not count in the list of attributesNames?

Dear Friend

Kindly check the following.

  1. We should the declare the property in the model.

  2. The property should be assigned with atleast one valiadtion rule for the current scenario.

public $password_repeat;

public function rules()



		return array(


			array('password_repeat', 'compare','compareAttribute'=>'password','message'=>'repeat password should match', 'on'=>'register'),




I’ve done exactly what you had done,but when you foreach ($model as $k=>$v),you will find that $password_repeat is not included in the array

$model->attributes = $_POST[‘registerForm’];

$_POST has the $password_repeat variable but $model does not.

Dear Friend

I feel sorry as things are not going our way.

I want to know whether you have included the current scenario when massively assigning the attributes.

    $reg=new User('register');//Here we have to include the scenario







Yii::app()->user->setFlash('Registeration','Thanking you for registering.Your registration is waiting for admin approval');