I have a trouble when implement “change of password” for memember. I first create a scenario “changepass” for validate data after the users send via form. And it work successfull. But when i set new password for model account and save it, I get a new record in database. I think the scenario is not exactly, then i set it again and and not happen any thing:" no new record, and don’t update"
My code below:
public function actionChangePass(){
$account = TblAccount::model()->findByPk(Yii::app()->user->id);
if(isset($_POST['TblAccount'])){
$account->setScenario('changepass');
$account->attributes =$_POST['TblAccount'];
$account->oldpassword = md5($account->oldpassword.Yii::app()->params['salt']);
if($account->validate()){
$account->setIsNewRecord(false);
$account->setScenario('update');
$account ->password = $account->oldpassword;
$account->save();
}else{
$account->oldpassword ="";
}
}
$this->render('changepass',array("acc"=>$account));
thank for everything.