The existence of beforeSave avoids saves to database

Hi folks. There is something very strangely, which happens to my model. Everything was fine until I made some final changes. I added beforeSave functionality, because I must hash the password before it is inserted as part of the row in the database.

The code looks like this:



	


	public function beforeSave(){


			


		$pass = $this->PASSWORD;


		$pass = md5(md5($this->PASSWORD).Yii::app()->params["salt"]);


		$this->PASSWORD = $pass;


	}


I had some doubts about save(false) so that I removed the false value of the argument, but I don't think this is the actual reason. I tested with just a declaration, or maybe it's more correctly to call it just an overriding, but the error and the clumsy behavior at all is 100% there.

I am creating a instance of the users class in the usersPerson controller. I think you may be interested in the final code:



$result1 = $users->validate("create");


		$result2 = $userpersons->validate("create");





		if($result1 && $result2)


		{


			


			


				


				$users->save(); // with false of course in production mode


			$userpersons->save(false);


			$this->redirect(array('show','id'=>$userpersons->USER_ID));


		}


		


Is this a bug or I am doing something not in the right manner?

You forgot return true in beforeSave()

Qiang, thanks! I had made the mistake just because I saw this method exists, but it was not used neither in the documentation, nor in the cookbook, so I didn't know how to use it exactly.