|
I've been trying to pass an array from one Controller to another without any luck. I've tried to use the Zend_Registry, but when I try to retrieve the value in the next Controller, I get an error "No entry is registered for key 'resultsAdmin'". So how is this done without resorting to redirects and such? I've tried using Zend_Session_Namespace(), but can't find any answers as to how to retrieve the value from the Namespace() once it is set. There has to be a way to create a globalized variable and access it, but how is it done in Zend? Thomas List |
|
Take a look at the Flash Messenger action helper...
http://framework.zend.com/manual/en/zend.controller.actionhelpers.html Gary/Spabby On 21 October 2010 17:49, Thomas List <[hidden email]> wrote: > > I've been trying to pass an array from one Controller to another without > any luck. I've tried to use the Zend_Registry, but when I try to retrieve > the value in the next Controller, I get an error "No entry is registered for > key 'resultsAdmin'". So how is this done without resorting to redirects and > such? I've tried using Zend_Session_Namespace(), but can't find any answers > as to how to retrieve the value from the Namespace() once it is set. There > has to be a way to create a globalized variable and access it, but how is it > done in Zend? > > Thomas List > |
|
Administrator
|
In reply to this post by Thomas List
-- Thomas List <[hidden email]> wrote
(on Thursday, 21 October 2010, 12:49 PM -0400): > I've been trying to pass an array from one Controller to another > without any luck. I've tried to use the Zend_Registry, but when I try > to retrieve the value in the next Controller, I get an error "No entry > is registered for key 'resultsAdmin'". So how is this done without > resorting to redirects and such? I've tried using > Zend_Session_Namespace(), but can't find any answers as to how to > retrieve the value from the Namespace() once it is set. There has to > be a way to create a globalized variable and access it, but how is it > done in Zend? What do you mean by "one controller to another", exactly? * Are you using _forward() or the ActionStack, and trying to pass data from one controller to the next using one of these? * Or are you talking about passing data between requests? The answers will be different based on how you answer those questions. In the case of the first, _forward() accepts an array of parameters to pass as the fourth argument (_forward($action, $controller, $module, $params)). ActionStack requires you to either update your request object and pass it (or create a new one and pass that), or use the actionToStack() method, which has the same signature as _forward(). In the case of the second, you'll need to pass the data using the session. Zend_Session_Namespace is quite easy: // Setting the data: $namespace = new Zend_Session_Namespace('someaction'); $namespace->data = $arrayOfData; // Retrieving the data: $namespace = new Zend_Session_Namespace('someaction'); $data = $namespace->data; -- Matthew Weier O'Phinney Project Lead | [hidden email] Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc |
|
In reply to this post by Gary Hockin
Alternatively, ignore me as I noticed you want to pass an array.
G On 21 October 2010 17:57, Gary Hockin <[hidden email]> wrote: > Take a look at the Flash Messenger action helper... > > http://framework.zend.com/manual/en/zend.controller.actionhelpers.html > > Gary/Spabby > > > On 21 October 2010 17:49, Thomas List <[hidden email]> wrote: > >> >> I've been trying to pass an array from one Controller to another without >> any luck. I've tried to use the Zend_Registry, but when I try to retrieve >> the value in the next Controller, I get an error "No entry is registered for >> key 'resultsAdmin'". So how is this done without resorting to redirects and >> such? I've tried using Zend_Session_Namespace(), but can't find any answers >> as to how to retrieve the value from the Namespace() once it is set. There >> has to be a way to create a globalized variable and access it, but how is it >> done in Zend? >> >> Thomas List >> > > > |
|
In reply to this post by weierophinney
Flash messenger isn't a bad idea. It's already designed to work within
controllers and has a built-in auto-destroy feature after 1 hop. It also supports arrays or objects that can be serialized. So if you're redirecting, the first request would set the data: $myArray = array(/* ... */); $this->_helper->flashMessenger->addMessage($myArray); In the following request you can pull it: $messages = $this->_helper->flashMessenger->getMessages(); $myArray = $messages[0]; -- *Hector Virgen* Sr. Web Developer Walt Disney Parks and Resorts Online http://www.virgentech.com
--
Hector Virgen |
| Powered by Nabble | Edit this page |
