/** * Creates a new Lang model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Lang(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Lang model. * If creation is successful, the browser will be redirected to the 'index' page. * @return mixed */ public function actionCreate() { $model = new Lang(); if ($model->load(Yii::$app->request->post())) { Yii::$app->response->format = Response::FORMAT_JSON; $errors = ActiveForm::validate($model); if (empty($errors)) { $model->save(false); } return $errors; } return $this->renderAjax('create', ['model' => $model]); }