I'm trying to build a multistep form (a.k.a. "wizard").
The excellent guide of Jeff Eaton 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 (partialy covered here):
There are two things that need to be done:
- Setting the current step index (1,2,3.../first,second,last etc.)
- 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?
Comments
I would be really interested
I would be really interested in any solutions as well. I was about to try exactly what you did - using hook_form_alter...so reading your findings saved me probably a whole heap of time.
Anyone any suggestions?
Sekrit Clues
In a multistep scenerio, be sure to check out $form['#parameters'] when altering a form. That's the complete list of data passed into the original form constructor -- including the $form_values collection.
--
Lullabot! | Eaton's blog | VotingAPI discussion
--
Eaton — Partner at Autogram
Did you mean $form['#post']?
I checked $form['#parameters'], but it never changes (a 2 members array).
However, I found $form['#post'] which allowed me to check $form['step'], during form_alter, and act upon it :-)
======================
Z.Stolar
linnovate.net - community content infrastructures
======================
Z.Stolar
iStolar Consulting
linnovate.net - Open Source Solutions
iStolar illustration
have you considered the
Have you considered the Pageroute module?
http://drupal.org/project/pageroute
you make several small cck types, but it displays them all as one.
j
Having one CCK form which is
Having one CCK form which is split, is not the same as having multiple CCKs somehow attached together.
While creating the form's workflow might be easier, it would certainly have implications on the way I can refer to that entity as a whole, won't it?
======================
Z.Stolar
iStolar Consulting
linnovate.net - Open Source Solutions
iStolar illustration
See new issue
See this issue: http://drupal.org/node/125145 .
--
http://www.reuniting.info/
Healing with Sexual Relationships.
http://www.wechange.org/
We live in a world of solutions.