public function actionCreate() { $model = new Setting(); if ($model->load(Yii::$app->request->post())) { if (Yii::$app->request->isAjax) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ActiveForm::validate($model); } else { if ($model->save()) { $this->flash('success', Yii::t('easyii', 'Setting created')); return $this->redirect('/admin/settings'); } else { $this->flash('error', Yii::t('easyii', 'Create error. {0}', $model->formatErrors())); return $this->refresh(); } } } else { return $this->render('create', ['model' => $model]); } }