Ver Mensaje Individual
  #10 (permalink)  
Antiguo 14/02/2011, 06:13
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

Ves, con codigo la gente se entiende mejor , deberia ser algo asi:

Bootstrap.php
Código PHP:
Ver original
  1. public function _initSession()
  2. {
  3.     Zend_Session::start(); 
  4. }

por recomendacón de Zend, cuando manipulas sesiones, el start debe ir en el bootstrap(para evitar errores)

TuController.php
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.         $form->isValid($ns->data);
  8.     }        
  9.     $this->view->form = $form;
  10. }
  11.  
  12. public function processAction()
  13. {
  14.     if (!$this->_request->isPost()) {
  15.         $this->_helper->redirector->gotoSimple('index');
  16.     }
  17.     $form = new Application_Form_Guestbook();
  18.     $post = $this->_request->getPost();                  
  19.     if (!$form->isValid($post)) {                
  20.         $ns = new Zend_Session_Namespace('formErrors');
  21.         $ns->setExpirationHops(1);
  22.         $ns->data = $post;
  23.         $this->_helper->redirector->gotoSimple('sign');
  24.     }
  25.     //do something
  26.     ...
  27.     $this->_helper->redirector->gotoSimple('result');
  28. }

que diferencia tenes a hacer algo como esto ?

Código PHP:
Ver original
  1. public function signAction()
  2. {      
  3.     $form = new Application_Form_Guestbook();
  4.     if($this->_request->isPost() &&
  5.         $form->isValid($this->_request->getPost())){
  6.         //do something
  7.        ...
  8.        $this->_helper->redirector->gotoSimple('result');  
  9.     }
  10.     $this->view->form = $form;        
  11. }
__________________
http://es.phptherightway.com/
thats us riders :)