我正在尝试更新用户密码,但无法保存
这是控制器代码:
public function actionChangepassword($id) {
    $model = new UserPass();
    $user = $this->findModel($id);
    if ($model->load(Yii::$app->request->post())) {
        if ($model->validate()) {
            try {
                $user->setPassword($_POST['UserPass']['newpass']);
                if (!$user->save()) {
                    Yii::$app->getSession()->setFlash('success', 'Password changed to ');
                    return $this->redirect(['indexi/'.$user->password]);
                } else {
                    Yii::$app->getSession()->setFlash('error', 'Password not changed');
                    return $this->redirect(['index']);
                }
            } catch (Exception $e) {
                Yii::$app->getSession()->setFlash('error', "{$e->getMessage()}");
                return $this->render('changepassword', [
                    'model' => $model
                ]);
            }
        } else {
            return $this->render('changepassword', [
                'model' => $model
            ]);
        }
    } else {
        return $this->render('changepassword', [
            'model' => $model
        ]);
    }
}
当我检查var_dump($_POST['UserPass']['newpass'])它有一个值时;
当我尝试更换零件时$user->setPassword($_POST['UserPass']['newpass']); 
$modeluser->password = $_POST['UserPass']['newpass'];
密码已保存但未散列,
什么可能是错的
这是setpassword功能
public function setPassword($password)
{
    $this->password = Yii::$app->security->generatePasswordHash($password);
}