When submitting a form POST data is not displayed

I have little experience with Zend Framework, but I like to play with it until it does not work. But now I can not solve this problem.

I have a form:

<?php class Application_Form_Login extends Zend_Form { protected $notEmpty; public function init() { // Create NotEmpty validator $notEmpty = new Zend_Validate_NotEmpty(); // Configure validators for username element $notEmpty->setMessage('Gelieve dit veld in te vullen'); $this->setMethod('post'); // emailAddress $this->addElement('text', 'emailAddress', array( 'filters' => array('StringTrim', 'StringToLower'), 'required' => true, 'validators' => array( array('validator' => $notEmpty), ), 'label' => 'Emailadres:' )); // password $this->addElement('password', 'password', array( 'filters' => array('StringTrim'), 'required' => true, 'validators' => array( array('validator' => $notEmpty), ), 'label' => 'Wachtwoord:' )); // submit $this->addElement('submit', 'submit', array( 'ignore' => true, 'label' => 'Inloggen' )); } } 

View:

 <?= $this->form ?> <?= $this->postdata ?> > <?= $this->form ?> <?= $this->postdata ?> 

And AccountController:

 <?php class AccountController extends Zend_Controller_Action { public function init() { echo 'data:'.$this->getRequest()->getPost('emailAddress'); /* Initialize action controller here */ } public function indexAction() { $this->view->postdata = var_dump($this->getRequest()->getParams()); $form = new Application_Form_Login(); $request = $this->getRequest(); if ($request->isPost()){ // THIS POINT IS NEVER REACHED if ($form->isValid($request->getPost())){ if ($this->_isValidLogin($form->getValues())){ // Succes Redirect to the home page $this->_helper->redirector('index', 'home'); } else // Not succes Redirect to account page { $this->_helper->redirector('index', 'account'); } } ($ this-> getRequest () -> getParams ()); <?php class AccountController extends Zend_Controller_Action { public function init() { echo 'data:'.$this->getRequest()->getPost('emailAddress'); /* Initialize action controller here */ } public function indexAction() { $this->view->postdata = var_dump($this->getRequest()->getParams()); $form = new Application_Form_Login(); $request = $this->getRequest(); if ($request->isPost()){ // THIS POINT IS NEVER REACHED if ($form->isValid($request->getPost())){ if ($this->_isValidLogin($form->getValues())){ // Succes Redirect to the home page $this->_helper->redirector('index', 'home'); } else // Not succes Redirect to account page { $this->_helper->redirector('index', 'account'); } } request-> getPost ())) { <?php class AccountController extends Zend_Controller_Action { public function init() { echo 'data:'.$this->getRequest()->getPost('emailAddress'); /* Initialize action controller here */ } public function indexAction() { $this->view->postdata = var_dump($this->getRequest()->getParams()); $form = new Application_Form_Login(); $request = $this->getRequest(); if ($request->isPost()){ // THIS POINT IS NEVER REACHED if ($form->isValid($request->getPost())){ if ($this->_isValidLogin($form->getValues())){ // Succes Redirect to the home page $this->_helper->redirector('index', 'home'); } else // Not succes Redirect to account page { $this->_helper->redirector('index', 'account'); } } ($ form-> getValues ())) { <?php class AccountController extends Zend_Controller_Action { public function init() { echo 'data:'.$this->getRequest()->getPost('emailAddress'); /* Initialize action controller here */ } public function indexAction() { $this->view->postdata = var_dump($this->getRequest()->getParams()); $form = new Application_Form_Login(); $request = $this->getRequest(); if ($request->isPost()){ // THIS POINT IS NEVER REACHED if ($form->isValid($request->getPost())){ if ($this->_isValidLogin($form->getValues())){ // Succes Redirect to the home page $this->_helper->redirector('index', 'home'); } else // Not succes Redirect to account page { $this->_helper->redirector('index', 'account'); } } 

As you can see, I added a comment: // THIS POINT NEVER REACHED. This controller has more features, but they are not relevant to my problem.

Let us explain this a little more. Very strange behavior is that when I put the data in their field, $ this-> view-> postdata = var_dump ($ this-> getRequest () → getParams () does not return the POST data. But when I put a note in the field login forms, I see the POST data. Of course, it is empty. Like this:

 array 'controller' => string 'account' (length=7) 'action' => string 'index' (length=5) 'module' => string 'default' (length=7) 'emailAddress' => string '' (length=0) 'password' => string '' (length=0) 'submit' => string 'Inloggen' (length=8) ' (length = array 'controller' => string 'account' (length=7) 'action' => string 'index' (length=5) 'module' => string 'default' (length=7) 'emailAddress' => string '' (length=0) 'password' => string '' (length=0) 'submit' => string 'Inloggen' (length=8) ' (length = array 'controller' => string 'account' (length=7) 'action' => string 'index' (length=5) 'module' => string 'default' (length=7) 'emailAddress' => string '' (length=0) 'password' => string '' (length=0) 'submit' => string 'Inloggen' (length=8) (length = array 'controller' => string 'account' (length=7) 'action' => string 'index' (length=5) 'module' => string 'default' (length=7) 'emailAddress' => string '' (length=0) 'password' => string '' (length=0) 'submit' => string 'Inloggen' (length=8) 

Thus, // THIS POINT never reaches actually achieved at the data input field in the room shape :-)

The question is, what am I doing wrong? I incorrectly handles Zend_Controller_Request_Http?

If you need more information, I must give it.

+1
source share
1 answer

Inclusion of a problem gives new ideas!

The problem is in my own code. At some point, I redirect to the same page. Forwarding means that $ _POST data is also cleared. This data, of course, does not come with a new page request.

So if someone has this problem with Zend Framework, that is, you do not get a POST or GET data to send your form, then you need to check your forwarding.

+1
source

All Articles