Ejemplo n.º 1
0
 function contactMe()
 {
     $form = new \SKS\LIB\Form();
     $form->post('name')->addRule('minlength', 2)->post('email')->addRule('email')->post("message")->addRule('minlength', 20);
     $errors = $form->validate();
     $email = new \SKS\DB\Entity\Email();
     $email->setName($this->getPostValue("name"));
     $email->setFrom($this->getPostValue("email"));
     $email->setContent($this->getPostValue("message"));
     $this->view->email = $email;
     if (isset($errors)) {
         $this->view->errors = $errors;
         $this->view->render('index/contactMe', false);
     } else {
         $email->persist(true);
         $sent = \EmailUtil::contact_us($email->getContent());
         if ($sent) {
             $this->view->message = "Thank you for contacting me, will get back to you soon..";
             $this->view->render('index/contactMe', false);
         } else {
             $this->view->error = "Error occured while sending email ..";
             $this->view->render('index/contactMe', false);
         }
     }
 }