/** * Creates a new Users model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Users(); if (Yii::$app->request->isPost) { $postInfo = Yii::$app->request->post(); if (!empty($postInfo)) { $postInfo['Users']['password'] = md5('111111'); if ($model->load($postInfo) && $model->save()) { $userInfo = ['name' => $model->username, 'name' => $model->name, 'name' => $model->name]; UsersInfo::addInfo(); Yii::$app->getSession()->setFlash('success', '添加成功!'); return $this->redirect(['view', 'id' => $model->id]); } else { throw new ServerErrorHttpException('添加用户失败,原因:' . json_encode($model->errors, JSON_UNESCAPED_UNICODE)); return $this->redirect(['create']); } } } else { return $this->render('create', ['model' => $model]); } }