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]); }
/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new UserForm(); $model->setScenario('create'); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } return $this->render('create', ['model' => $model, 'roles' => ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'name')]); }
/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new UserForm(); $model->setScenario('create'); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } return $this->render('create', ['model' => $model, 'roles' => User::getCustomRoles(), 'domains' => $this->_getDomainsArray()]); }