public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
         Yii::$app->session->setFlash('contactFormSubmitted');
         return $this->refresh();
     }
     return $this->render('contact', ['model' => $model]);
 }
 /**
  * @return string|\yii\web\Response
  */
 public function actionContact()
 {
     $modelPage = Page::currentPage();
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->session->setFlash('success', Yii::t("app/contact", "Thank you for contacting us. We will respond to you as soon as possible.", ['dot' => false]));
             return $this->refresh();
         }
         Yii::$app->session->setFlash('error', Yii::t("app/contact", "There was an error sending email.", ['dot' => false]));
     }
     return $this->render('contact', ['model' => $model, 'modelPage' => $modelPage]);
 }
Example #3
0
 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]);
     }
 }