Ejemplo n.º 1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (!Yii::$app->user->can(LetArticle::moduleName() . ':create')) {
         return $this->render('//message', ['messages' => ['danger' => Yii::t('yii', 'You are not allowed to perform this action.')]]);
     }
     $model = new LetArticle();
     if ($model->load(Yii::$app->request->post()) and $model->save()) {
         if (Yii::$app->request->post('save_type') == 'apply') {
             return $this->redirect(['update', 'id' => $model->id]);
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }