Can't find where's the error..

Module: (the class is basically empty. it just extends User that has all the standard gii-made code)


class SiteUser extends User

{   

    /**

     * Needed for changing password

     */

    public $newPassword;

    public $newPasswordConfirm;


	public function rules()

	{

            array('newPassword', 'compare', 'compareAttribute'=>'newPasswordConfirm', 'on'=>'register, changePassword'),

            array('newPassword', 'required', 'on'=>'register'),

	    array('dateUpdated, lastLogin, password, newPassword, newPasswordConfirm', 'safe'),

            ... more stuff...

	}

    

	public function attributeLabels()

	{

	    ... some stuff...

	}    

}

Controller: (update action and loadmodel function only)


	public function actionUpdate($id)

	{

		$model=$this->loadModel($id);


		// Uncomment the following line if AJAX validation is needed

		// $this->performAjaxValidation($model);


		if(isset($_POST['SiteUser']))

		{

			$model->attributes=$_POST['SiteUser'];

            

            if ($model->newPassword !== '') {

              $model->setScenario('changePassword');

            }

            

			if($model->validate())

            {

                if ($model->newPassword !== '') {

                    $model->password = $model->hashPassword($model->new_password);

                }

                if($model->save(false))

                    $this->redirect(array('view','id'=>$model->id));

                

            }

		}


		$this->render('update',array(

			'model'=>$model,

		));

	}


	public function loadModel($id)

	{

		$model = SiteUser::model()->findByPk($id);

		if($model===null)

			throw new CHttpException(404,'The requested page does not exist.');

		return $model;

	}

Opening user/update&id=1 I get:


CException


Property "User.newPassword" is not defined.

I don’t understand why it’s loading User class instead of SiteUser class!

You have to override User::model() in SiteUser class to make it work properly.

Cool! It works!! thank you very much!!