Ejemplo n.º 1
0
 /**
  * Displays the contact static page and sends the contact email.
  *
  * @return string|\yii\web\Response
  */
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->contact(Yii::$app->params['adminEmail'])) {
             AppHelper::showSuccessMessage(Yii::t('site', 'Thank you for contacting us. We will respond to you as soon as possible.'));
         } else {
             AppHelper::showSuccessMessage(Yii::t('site', 'There was an error sending email.'));
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
 /**
  * Displays contact page.
  *
  * @return mixed
  */
 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', Yii::t('app', 'Спасибо за ваш вопрос.'));
         } else {
             Yii::$app->session->setFlash('error', Yii::t('app', 'Ошибка отправки сообщения.'));
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }