public function actionAddadminuser() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $req = Yii::$app->request; //创建一个请求对象 $form = new AdminUserForm(); //添加 $form->setScenario('create'); if ($form->load($req->post()) && $form->validate()) { if ($user->addAdminUser($form->username, $form->password, $form->mobile, $form->role, $form->status)) { $this->redirect(Variable::$adminUserManger_url); return; } $form->addError('', '添加失败,请检查数据'); } return $this->render(Variable::$addAdminUser_view, ['model' => $form]); }