'Twas brillig, and debussy007 at 21/09/10 18:58 did gyre and gimble:
> I need to pass an array between two actions.
> Below is the code I tried :
>
> in action 1 :
> return $this->_redirector->gotoSimple('time-slots', NULL , NULL,
> array('bookings' => $bookings));
>
> in action 2 (timeSlotsAction) :
> $bookings = $this->_getParam('bookings');
>
> Unfortunately this won't work. I am doing something wrong. So I thought I
> should serialize the array but I am afraid that the serialized output will
> be to big for a GET param.
>
> Thank you for any help !!
Take a look at the way the flash messenger helper works. It's a one
shot, pass a message to the next request system.
I've used this as a basis to create a "flashform" helper which can pass
form values from one request to another.
I use this in the same way as one would normally use flash messenger -
i.e. flash messenger can be used to pass a "failed" or "succeeded"
message to the user, but if I fail I may want to keep the (invalid) form
values to give back to the user to retry.
I do this to implement a PRG system (Post, Redirect, Get) in order to
not break the browser's "back" button:
[GET] Use Zend_Form to give the user some input fields
[POST] User changes values and submits form
if ($valid) { $flashMsg = "Succeed"; }
else { $flashMsg = "Failed"; $flashForm = $form->getRawValues(); }
redirect();
[GET] Repopulate form if $flashForm has values. Show form again + $flashMsg.
Col
--
Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/
Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
Mageia Contributor [http://www.mageia.org/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]