public function actionCreate() { $model = new Carousel(); 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 { $model->status = Carousel::STATUS_ON; if ($model->save()) { $this->flash('success', Yii::t('easyii/carousel', 'Carousel created')); return $this->redirect(['/admin/' . $this->module->id]); } else { $this->flash('error', Yii::t('easyii', 'Create error. {0}', $model->formatErrors())); } return $this->refresh(); } } else { return $this->render('create', ['model' => $model]); } }