I am new to Yii. I have created password changing form, page name is change. In that page there are three fields old password, new password and confirm new password fields.
My rule
public function rules() {
return array(
array('old_password, confirm_password, str_user_password', 'required',
'on' => 'change'),
array('confirm_password', 'compare', 'compareAttribute' => 'str_user_password',
'message' => 'Password Must Be same.', 'on' => 'change'),
);
}
Controller
public function actionChange($id)
{
$model=new User('change');
//$model->setScenario('change');
$model=$this->loadModel($id);
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
if($model->save())
$this->redirect(array('view','id'=>$model->int_user_id));
}
$this->render('change',array(
'model'=>$model,
));
}
create and update page validation work. I have copied it into update page it is working perfectly. I think it's scenario problem. Please help me to find a solution.