예제 #1
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');
 }