示例#1
0
 /**
  * Creates a new Post model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Post();
     $model->load(Yii::$app->request->get());
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('postSaved');
         return $this->redirect(['update', 'id' => $model->id]);
     }
     if ($model->type->show_category) {
         $model->setScenario('required_category');
     }
     return $this->render('create', ['model' => $model]);
 }