public function actionIndex()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
         Yii::$app->session->setFlash('contactFormSubmitted');
         return $this->refresh();
     } else {
         return $this->render('index', ['model' => $model]);
     }
 }
Exemple #2
0
 public function actionContact()
 {
     $formModel = new ContactForm();
     $model = $this->loadPage('contact');
     if ($formModel->load(Yii::$app->request->post()) && $formModel->validate()) {
         Notification::contactNotify($formModel->attributes);
         Yii::$app->session->setFlash('contactFormSubmitted');
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model, 'formModel' => $formModel]);
     }
 }
 /**
  * Displays contact page.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $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('index', ['model' => $model]);
     }
 }
 public function actionIndex()
 {
     $model = new ContactForm();
     if ($user = Yii::$app->user->identity) {
         /** @var \app\modules\user\models\User $user */
         $model->name = $user->username;
         $model->email = $user->email;
     }
     if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
         Yii::$app->session->setFlash('contactFormSubmitted');
         return $this->refresh();
     } else {
         return $this->render('index', ['model' => $model]);
     }
 }