/** * Creates a new Announcement model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Announcement(); if ($model->load(Yii::$app->request->post())) { $model->setAttributes(array('user_fk' => Yii::$app->user->identity->user_id)); } if ($model->save()) { return $this->redirect(['view', 'id' => $model->announcement_id]); } else { return $this->render('create', ['model' => $model]); } }