/** * 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($_POST['Post'])) { $model->attributes = $_POST['Post']; $model->setAttribute('id', $model->id); $model->setAttribute('nama', Yii::$app->user->identity->nama); $model->setAttribute('kategory_forum', Yii::$app->session['forum_id']); $model->setAttribute('judul', $model->judul); $model->setAttribute('isi_post', $model->isi_post); if ($model->save()) { Yii::$app->getSession()->setFlash('success', 'Posting Anda telah ditambahkan'); $this->redirect(['index']); } } else { return $this->render('create', ['model' => $model]); } }