/** * Creates a new Contact model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Contact(); $infoCompany = Infocompany::findOne(['id' => 1]); if ($model->load(Yii::$app->request->post())) { $model->fullname = $_POST['genderName'] . " " . $model->fullname; if ($model->save()) { //return $this->redirect(['create', 'id' => $model->id]); Yii::$app->session->setFlash('contactFormSubmitted'); return $this->refresh(); } } else { return $this->render('create', ['model' => $model, 'infoCompany' => $infoCompany]); } }
/** * Finds the Infocompany model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Infocompany the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Infocompany::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }