Example #1
0
 /**
  * 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()]);
     }
 }