/** * 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 User(); $model->scenario = User::SCENARIO_USER_CREATE; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model]); } }
/** * 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 User(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { $model->setPassword($model->password_hash); $model->created_at = time(); $model->updated_at = time(); $model->status = 10; $model->generatePasswordResetToken(); $model->generateAuthKey(); $model->save(); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new User model. * @return mixed */ public function actionCreate() { $model = new User(); $model->setScenario('create'); if (Yii::$app->request->isPost) { $model->load(Yii::$app->request->post()); Yii::$app->response->format = 'json'; if ($model->save()) { return Yii::$app->params['response']['success']; } else { return ActiveForm::validate($model); } } else { return $this->renderAjax('create', ['model' => $model, 'roles' => AuthItem::getRoles()]); } }