|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
public function actionContact() { $model = new ContactForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($model->sendEmail(Yii::$app->params[‘adminEmail‘])) { Yii::$app->session->setFlash(‘success‘, ‘Thank you for contacting us. We will respond to you as soon as possible.‘); } else { Yii::$app->session->setFlash(‘error‘, ‘There was an error sending email.‘); } return $this->refresh(); } else { return $this->render(‘contact‘, [ ‘model‘ => $model, ]); } } |
参见自带SiteController.php中Contact方法
|
1
|
return $this->refresh(); |
这行代码即可