public function indexAction()
 {
     $this->view->headScript()->appendFile('//www.google.com/recaptcha/api.js');
     $this->view->addHelperPath(APPLICATION_PATH . '/../vendor/wendrowycz/zf1-recaptcha-2/src/Wendrowycz/View/Helper', 'Wendrowycz\\View\\Helper\\');
     $request = $this->getRequest();
     $form = new Application_Form_Contact();
     if ($request->isPost() && $form->isValid($_POST)) {
         $values = $form->getValues();
         unset($values['g-recaptcha-response']);
         $this->view->values = $values;
     }
     $this->view->form = $form;
 }
 public function addAction()
 {
     $form = new Application_Form_Contact();
     if ($this->_request->isPost()) {
         $data = $this->_request->getPost();
         if ($form->isValid($data)) {
             $dataFiltrees = $form->getValues();
             $contact = new Application_Model_Contact();
             $contact->setPrenom($dataFiltrees['prenom'])->setNom($dataFiltrees['nom'])->setEmail($dataFiltrees['email'])->setTelephone($dataFiltrees['telephone']);
             $this->mapper->insert($contact);
             $this->_flashMessenger->addMessage('Le contact ' . $contact->getPrenom() . ' a bien été créé');
             $this->_redirector->gotoRouteAndExit(['controller' => 'contact'], null, true);
         }
     }
     $this->view->contactForm = $form;
 }
Example #3
0
 public function updateAction()
 {
     if (!$this->_hasParam('id')) {
         return $this->_redirect('/contact/index/page/1');
     }
     $form = new Application_Form_Contact();
     $persons = new Application_Model_Contacts();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->_getAllParams())) {
             $model = new Application_Model_Contacts();
             $model->save($form->getValues(), $this->_getParam('id'));
             return $this->_redirect('/contact/index/page/1');
         }
     } else {
         $row = $persons->getRow($this->_getParam('id'));
         if ($row) {
             $form->populate($row->toArray());
         }
     }
     $this->view->form = $form;
 }