Reputation: 223
I want to redirect to a page from a controller in zend. Before redirection I want to set some values in the request object and then I want to get these values on the controller where I have redirected.
I can do it by query string but I dont want to send these values in URL.
Please let me know:
The main aim is to avoid using query sting. Let me know the solution.
Thanks in advance.
Pravin
Upvotes: 1
Views: 265
Reputation: 7954
You can use Zend Flashmessenger although it is used for showing messages..you can do it for this also
Assuming you get ur post values in FooController/barAction
public function barAction(){
$flashMessenger = $this->_helper->getHelper('FlashMessenger');
$val1 = $this->_request->getPost('val1');
$val2 = $this->_request->getPost('val2');
$flashMessenger->addMessage(array('val1' => $val1 ,'val2' => $val2));
$this->_redirect('somecontroller/someaction');
}
Then in someaction,
public function someAction(){
$flashMessenger = $this->_helper->getHelper('FlashMessenger');
$this->view->flashmsgs = $flashMessenger->getMessages(); //This will get you the array
}
Upvotes: 0
Reputation: 12142
Have you tried using this before redirect
$something = new Zend_Session_Namespace('abc');
$something->other = 123;
and then extract the data with
$something = new Zend_Session_Namespace('abc');
if (isset($something->other))
{
$my_var = $something->other;//that is 123
}
Upvotes: 2
Reputation: 131
If session is not acceptable then I can see two ways:
use _forward method and execute new action in scope of current request http://framework.zend.com/manual/en/zend.controller.action.html#zend.controller.action.utilmethods
use empty page that contains form with hidden elements that will be automatically submitted by javascript
Upvotes: 3