Exemple #1
0
 public function actionCreate($slug = null)
 {
     $model = new Faq();
     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/faq', 'Entry created'));
                 return $this->redirect(['/admin/' . $this->module->id]);
             } else {
                 $this->flash('error', Yii::t('easyii', 'Create error. {0}', $model->formatErrors()));
                 return $this->refresh();
             }
         }
     } else {
         if ($slug) {
             $model->slug = $slug;
         }
         return $this->render('create', ['model' => $model]);
     }
 }