/** * Creates a new Suggestion model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Suggestion(); if ($model->load(Yii::$app->request->post())) { $model->submitter = Yii::$app->user->id; if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Suggestion model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionAdd() { $model = new Suggestion(); if (Yii::$app->request->post()) { $model->submitter = Yii::$app->user->id; $model->load(Yii::$app->request->post()); if ($model->save()) { Yii::$app->session->setFlash('success', '感谢您的提议,我们会尽快回复'); } else { Yii::$app->session->setFlash('error', '发送失败'); } error_log(print_r($model->errors, true)); return $this->refresh(); } return $this->render('add', ['model' => $model]); }