> Does anyone have used CGI::Application::Plugin::FormState together with
> CGI::Application::Dispatch?

I do.  At the moment, I'm using a custom subclass of
CGI::Application::Dispatch v1, but I hope to upgrade to version 2 soon.

Here's how I handle redirects:

$self->redirect("/step2/?cap_form_state=".$self->form_state->id );

So I'm just passing cap_form_state as a regular URL query parameter. 
This works for me.

> After successful validation of each form I use a call like:
> return $self->redirect('/step2/' . $self->form_state->id);
> to go to the next one, because CGI::Application::Dispatch is in use.
>
> By C::A::Dispatch module, the 'cap_form_state' param is not set to the
> $self->query object , but to $self->param
> and after the redirection the new form's $self->query has a new random
> string value for 'cap_form_state' param.
> A call like:
> $self->query->param('cap_form_state', $self->param('cap_form_state');
> doesn't seem to work in the runmode (to late?)

If I understand you correctly, you're using C::A::Dispatch to parse the
form state id from the URL and then passing it into the new app via a
C::A param, right?  Then in the new app, you're stuffing the id into the
$self->query object where CAP::FormState expects it?

I think this should work fine, as long as you take care to put this
value in the query object before your first call to $self->form_state.

The first time you call $self->form_state the plugin will try to fetch
the id from the query object using code like this:

   my $storage_hash  = $webapp->query->param('cap_form_state')
                     || $webapp->query->url_param('cap_form_state');


Are you calling $self->form_state->config somewhere earlier in your
app (e.g. cgiapp_init or cgiapp_prerun)?  If you are, then you need
to stuff the form state id in the query object before you do this.

> And BTW, is it possible to pass hashrefs between forms, like:
> $self->form_state->param('step1' => $valid_results_ref);
> and retrieve in on the 'next' form? Or do I have to use something like
> Storable.pm first on the hashref?

Anything you can store in the user's session should be safe to store in
a formstate param.  So the only things you should avoid are objects,
which require special care when re-vivifying.


Michael


---
Michael Graham <[EMAIL PROTECTED]>


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to