public function actionCreate() { $model = new History(); 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->validate() && $this->send($model)) { $this->flash('success', Yii::t('easyii/subscribe', 'Subscribe successfully created and sent')); return $this->redirect(['/admin/subscribe/a/history']); } else { $this->flash('error', Yii::t('easyii', 'Create error. {0}', $model->formatErrors())); return $this->refresh(); } } } else { return $this->render('create', ['model' => $model]); } }