예제 #1
0
 private function saveForm(\Kodazzi\Form\FormBuilder $Form)
 {
     $View = $this->getView();
     $post = $this->getPOST();
     $errors = array();
     if (is_array($post) && count($post)) {
         $Response = $this->forward('Dinnovos\\Amazonas:Captcha:isValidCaptcha', array(), array(), $post);
         $data = json_decode($Response->getContent());
         if (!isset($data->status) || isset($data->status) && $data->status != 'ok') {
             $errors['captcha'] = 'EL código de seguridad es incorrecto.';
         }
         $name_form = $Form->getNameForm();
         $post[$name_form]['status'] = 0;
         $Form->bind($post);
         if ($Form->isValid() && count($errors) == 0) {
             $result = $Form->save();
             if ($result) {
                 $this->getView()->msgSuccess('Su mensaje fue enviando correctamente.');
                 try {
                     $this->sendContact($post[$name_form]);
                 } catch (\Exception $a) {
                 }
                 return true;
             } else {
                 $this->getView()->msgError('Ocurrio un error al enviar el mensaje, por favor intente más tarde');
             }
         } else {
             $this->getView()->msgError('El formulario tiene algunos errores.');
         }
     }
     $View->set(array('form' => $Form, 'errors' => $errors));
 }
 protected function saveFormSlide(\Kodazzi\Form\FormBuilder $Form, $id_carousel)
 {
     $View = $this->getView();
     if ($Form->bindRequest($this->getRequest())) {
         if ($Form->isValid()) {
             $result = $Form->save();
             if ($result) {
                 $View->msgSuccess('El registro fue almacenado correctamente.');
                 return $this->redirectResponse($this->buildUrl($this->default_route, array('controller' => $this->controller, 'action' => 'add', 'param1' => $id_carousel)));
             }
         }
         $View->msgError('Ocurrio un error, por favor verifique el formulario');
     }
     $View->set(array('form' => $Form));
 }
예제 #3
0
 protected function saveForm(\Kodazzi\Form\FormBuilder $Form, $Item = null)
 {
     $View = $this->getView();
     $post = $this->getRequest()->request->all();
     $name_form = $Form->getNameForm();
     if ($this->isPost() && array_key_exists($name_form, $post)) {
         $Form->bind($post);
         if ($Form->isValid()) {
             $result = $Form->save();
             if ($result) {
                 $View->msgSuccess('El registro fue almacenado correctamente.');
                 return $this->redirectResponse($this->buildUrl($this->default_route, array('controller' => $this->controller, 'action' => 'list')));
             }
         }
         $View->msgError('Ocurrio un error, por favor verifique el formulario');
     }
     $View->set(array('form' => $Form));
 }
예제 #4
0
 protected function saveForm(\Kodazzi\Form\FormBuilder $Form)
 {
     $View = $this->getView();
     $post = $this->getPOST();
     $name_form = $Form->getNameForm();
     $post[$name_form]['token_email'] = $this->createToken($this->getTimestamp());
     $post[$name_form]['token_email_created'] = $this->getTimestamp();
     $post[$name_form]['email_confirm'] = '0';
     $post[$name_form]['status'] = $this->need_approval ? 2 : 1;
     if ($Form->bind($post)) {
         if (array_key_exists('UserForm', $post) && array_key_exists('accept_terms', $post['UserForm']) && $post['UserForm']['accept_terms'] != 1) {
             $Form->setError('accept_terms', 'Debe aceptar los términos y condiciones.');
         }
         if ($Form->isValid()) {
             $result = $Form->save();
             if ($result) {
                 $last_id = $Form->getIdentifier();
                 // Enviar email de confirmacion
                 $this->sendWelcomeAndTokenConfirmation($last_id);
                 $View->msgSuccess('Felicitaciones!! el registro ha sido exitoso.');
                 // Si se permite iniciar sesion luego del registro...
                 if ($this->start_after_registration) {
                     $User = $this->getDB()->model($this->model)->fetch(array('id' => $last_id));
                     if ($User) {
                         // Crea la tarjeta en la sesion del usuario.
                         $this->createUserCard($User);
                         return $this->redirectResponse($this->buildUrl($this->route_landing));
                     }
                 }
                 return $this->redirectResponse($this->buildUrl('user-successful-registration'));
             }
             return $this->redirectResponse($this->buildUrl('user-registration-fails'));
         }
         $View->msgError('Ocurrio un error, por favor verifique el formulario');
     }
     $View->set(array('form' => $Form));
 }