/** * 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(); if (isset($_GET['type'])) { $_GET['Post']['type_id'] = $_GET['type']; } elseif (empty($_GET)) { $_GET['Post']['type_id'] = 6; } $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]); }