Ver Mensaje Individual
  #15 (permalink)  
Antiguo 15/02/2011, 11:05
Avatar de masterpuppet
masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Formulario -> Proceso -> Resultado

A ver esta es una versión mejorada,

Código PHP:
Ver original
  1. public function signAction()
  2. {
  3.     $form = new Application_Form_Guestbook();
  4.     $form->setAction(Zend_Controller_Front::getInstance()->getBaseUrl() . '/guestbook/process');
  5.     if(Zend_Session::namespaceIsset('formErrors')) {
  6.         $ns = new Zend_Session_Namespace('formErrors');
  7.         foreach($ns->errors as $field => $errors) {
  8.             $form->getElement($field)->addErrors($errors);             
  9.         }
  10.     }        
  11.     $this->view->form = $form;
  12. }
  13.  
  14. public function processAction()
  15. {
  16.     if (!$this->_request->isPost()) {
  17.         $this->_helper->redirector->gotoSimple('index');
  18.     }
  19.     $form = new Application_Form_Guestbook();
  20.     if (!$form->isValid( $this->_request->getPost())) {                
  21.         $ns = new Zend_Session_Namespace('formErrors');
  22.         $ns->setExpirationHops(1);
  23.         $ns->errors = $form->getMessages();
  24.         $this->_helper->redirector->gotoSimple('sign');
  25.     }
  26.     //do something
  27.     ...
  28.     $this->_helper->redirector->gotoSimple('result');
  29. }

Saludos.
__________________
http://es.phptherightway.com/
thats us riders :)