[support] How to create a multistep CCK form?

Zohar Stolar z.stolar at gmail.com
Tue Jan 30 21:55:59 UTC 2007


I'm trying to build a multistep form (a.k.a. "wizard").
The excellent guide of Jeff Eaton <http://drupal.org/node/101707> 
(http://drupal.org/node/101707) about how to do such a form, relates 
only to a user-supplied form (you need to write a special module for it).
I wonder if there's a way to do the same thing with a CCK form. Here are 
the issues I ran into so far:

There are two things that need to be done:

   1. Setting the current step index (1,2,3.../first,second,last etc.)
   2. Determining which step we're at, to decide which form fields to
      present, or which action to perform, upon submitting.

To set the current step index, Eaton uses the $form_values array which 
is automaticaly added to a multistep form. He's doing so in the form 
building function (/function my_form/), with the aid of $form_values. 
This way he assures the step won't be increased until proper validation.
If I want to do the same thing on an existing form, I'd have to use 
hook_form_alter. The thing is $form_values is not available to 
hook_node_alter...

Hook_submit is used by Eaton to check on which step we are currently at, 
and act upon it. The equivalent in the case of altering a form, would be 
to use hook_nodeapi, during the submit operation. But then again - I 
think I can't really hold the process, only add things to it.

So basicaly I'm asking: *Is there a different way to modify a CCK, so it 
will become a multistep form?*


Zohar



More information about the support mailing list