public function actionEdituser() { $req = Yii::$app->request; //创建一个请求对象 $form = new UserForm(); $form->setScenario('update'); $id = trim($req->get('id')); if (!is_numeric($id) || $id == 0) { $this->redirect(Variable::$userMange_url); return; } //修改 if ($form->load($req->post()) && $form->validate()) { $isSuccess = (new User())->updateCusetomer($id, $form->realName, $form->nickName, $form->password, $form->email, $form->mobile, $form->userType, $form->userStatus, $form->frozenReason, $form->comeFrom); if ($isSuccess) { $form->addError('', '资料更新成功'); } else { $form->addError('', '资料更新失败'); } } $userModel = User::findOne($id); $form->realName = $userModel->realName; $form->nickName = $userModel->nickName; $form->password = $userModel->password; $form->email = $userModel->email; $form->mobile = $userModel->mobile; $form->userType = $userModel->userType; $form->userStatus = $userModel->userStatus; $form->frozenReason = $userModel->frozenReason; $form->comeFrom = $userModel->comeFrom; return $this->render(Variable::$editUser_view, ['model' => $form, 'userModel' => $userModel]); }