[support] D6 form submit (not), cache, double redirect back and reload from cache?

Christopher M. Jones cjones at partialflow.com
Tue Nov 23 00:33:43 UTC 2010


Definitely the multistep form approach is right on for this. Everything 
you describe is accomplished by setting form_state['storage']. There are 
no redirects to sub forms which require posting back to the main one. 
You simply build the form over and over with different elements 
depending on values in form_state['storage']. Storage persists 
throughout the life of the form.

There are several howtos out there. Google is your friend. However, 
ctools provides an api for building multistep forms, and ahah helper 
module provides away for doing it with ajax goodness.


On 11/22/2010 07:19 PM, Carl Wiedemann wrote:
> This message might be better for the development list rather than the
> support list.
>
> Would crafting the entire form as a single multi-step work for you?
> Consider this example:
> http://www.benjeavons.com/multi-step-forms-drupal-6-using-variable-functions
>
> On Mon, Nov 22, 2010 at 4:31 PM, Doug <doug.duboulay at gmail.com
> <mailto:doug.duboulay at gmail.com>> wrote:
>
>     Writing a D6 module.
>     I'm trying to build a lengthy form, where at some point, towards
>     the bottom of the form, it would be nice to
>     (1) optionally hit an 'incomplete'/branch submit handler,
>     (2) cache the interim curent form state,
>     (3) double redirect to a new form (create submit ) etc
>     (4) bounce back to the original (with second redirect),
>     (5) reload interim state from the cache,
>     (6) amend with new details gleaned from the intermediate/branch form,
>     (7) finally proceed to the "complete" form submit handler of
>     original form
>
>     Currently I can double redirect to a second form, but on bounce back,
>     all the original details are lost, which is really unintuitive to
>     the user, who thinks they've already filled out that part.
>
>     I guess I need to do something like this:
>
>     function mymodule_interim_submit($form, &$form_state) {
>       $form_build_id = $form_state['values]['form_build_id'];
>       unset($form_state['submitted']);
>       unset($form_state['storage']);  // $form_state['rebuild'] = FALSE;
>       $form_state['saved']= $form_state['values];
>       $form_state['redirect'] = array (   // double redirect
>     'mymodule/intermediate_form',
>     'mymodule/this_form/' . $form_build_id
>       );
>     }
>
>     But I don't know if thats sufficient to preserve the interim state
>     of the form, or will it still be deleted from the cache after
>     the interim_submit completes, or ...(barking up wrong tree)?
>
>     thanks
>     Doug
>     --
>     [ Drupal support list | http://lists.drupal.org/ ]
>
>


More information about the support mailing list