Ejemplo n.º 1
0
 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]);
 }
Ejemplo n.º 2
0
 /**
  * Saves the contact information in the database
  */
 public function sendAction()
 {
     if ($this->request->isPost() != true) {
         return $this->forward('contact/index');
     }
     $form = new ContactForm();
     $contact = new Contact();
     // Validate the form
     $data = $this->request->getPost();
     if (!$form->isValid($data, $contact)) {
         foreach ($form->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->forward('contact/index');
     }
     if ($contact->save() == false) {
         foreach ($contact->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->forward('contact/index');
     }
     $this->flash->success('Thanks, we will contact you in the next few hours');
     return $this->forward('index/index');
 }