Reassigning Attributes After Form Submission

Hey all :)

I have a registration form that extends CActiveRecord and is based on a user table.  Validation is setup and working fine but I noticed in the code below that I cannot set $form->password to a value other than the one submitted on the form.

In this code, if the form validates, I'm trying to encrypt the password and assign it to $form->password, then save it to the database.  With the $form->password line commented out, a new user record is added to the database in plain text (for testing).  If I uncomment it (to store the encrypted password), the activation email goes out and the render occurs, but the insert to db silently fails.

I turned on logging with trace, etc., but I still can't see what's going on.

Any ideas?

	public function actionRegistration()


	{


		$scriptSet = new ScriptSet;


		$scriptSet->loadSet('mainRegistration', null, 'ie', 1);


		


		$form = new User;


		


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


		{


			$form->attributes=$_POST['User'];


			


			if($form->validate())


			{


				$salt="<A Salt>"; //omitted


				$string = "$salt" . $_POST['User']['password'];


				


				$form->created   = new CDbExp​ression('NOW()');


				$form->modified  = new CDbExp​ression('NOW()');


				//$form->password = sha1($string);


				$form->lastIp   = $_SERVER['REMOTE_ADDR'];


				$form->save();


				


				// Send Activation email


				...


				


				// Render success


				...		


			}


		}


		


		//Display initial registration page			


		...


	}


I'm no expert at all but try this;

from

$form->save

to

$form->save(false)

as validation has already occured

Gah, yes indeed.

Thanks, ooaat :)