I have a form on my index, and when it valid, it redirects to a new view, and i want on that new view to get the name that was entered in the form, how can i do that?
my controller:
public function indexAction()
{
// action body
$eform = new Application_Form_Eform();
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($eform->isValid($formData)) {
$nameInput = $eform->getValue('nameInput');
$this->_helper->redirector->gotoRoute(array('controller'=> 'index','action' =>'result', 'email' => $nameInput));
$this->_helper->redirector('result');
exit;
} else {
$eform->populate($formData);
}
}
$this->view->form = $eform;
}
public function resultAction()
{
$nameInput = $this->_getParam('email');
$this->view->email = $nameInput;
}
result.phtml
<?php echo $this->name;?>
how can i pass the variable name
that was entered in the form and display it on the new view of resultAction
? Thanks!
You don't need to execute
Zend_Controller_Action_Helper_Redirector::direct
method afterZend_Controller_Action_Helper_Redirector::gotoRoute
, leave only the first call, and usegotoRouteAndExit
instead:If I correctly understood question. You want send param URI when redirecting. So you can try this.