Multistep forms for CCK

Last modified: October 19, 2009 - 16:00

The Multistep module adds multiple-step functionality to CCK forms. It does so by assigning a step number to each fieldgroup within the content type and hiding all the groups that do not belong to the current step. The user can then use different submitting buttons that will redirect to the previous, next, or current step.

The module also provides a block for each content type with a menu of the different groups within that form and a progress bar. This provides an easy way to jump to different steps throughout the form without having to go one by one as well as keeping track of the progress of the form.

Usage

To use this module, go into the content type editing form in Administer >> Content management >> Content types and select the content type you want to enable the multistep for.

There will be a collapsed Multistep Form section below, mark it as Enabled and enter the amount of steps that you want this form to span.

Now, whenever you add or edit a group, you will be able to select which step that group belongs to. The group will only be shown when in that step, or in all of them if All is selected as an option.

If you are configuring multistep for a content type that already had data previously, you should go to Administer >> Site configuration >> Multistep and reset the table for that content type. This will create step data for all nodes that were previously created.

If you have a Taxonomy vocabulary set for the content type, you will see an option to set which step it should belong to in the content type editing form.

Configuring form settings

When you enable multistep for a node type, you can change several options that will affect different aspects of the form.

To remove/show the original buttons on the node editing form (Preview, Delete), go to the content type editing form in Administer >> Content management >> Content types and check/uncheck the box that says Hide standard buttons.

To change the text that appears on the different buttons of the form (Previous, Next, Save, Done), go to the admin settings page in Administer >> Site configuration >> Multistep and modify the values shown in the Navigation button labels section.

Form toggle

Users with the toggle multistep permission can select whether to view the entire form in a single page or the multistep form split over multiple pages. This is useful for vieweing a whole form at a glance before starting to enter the data.

You can also set whether the default display of the form is the multistep form or the entire form. Only users with the toggle multistep permissions will be able to switch displays.

Block: form index and progress bar

For each content type in which you enable multistep, a block will be created. This block will contain an index of all the fieldgroups in the form and a progress bar.

The index will allow the user to jump among the different parts of the form. If an item is displayed in italics, it meas that the step that fieldgroup belongs to has not been submitted yet. This way the user can keep track of the sections of the form needed to complete it.

The progress bar, on the other hand, will display a bar that will grow with each step submitted. The percentage on the bar is calculated based on the number of steps that have been submitted and the total number of steps. It does not imply order.

You can configure the block to display either the index, the progress bar, or both.

Development

A hook is provided in case you want to override the status of a step when you submit a form. The hook would be implemented as:

<?php
hook_multistep_update_status
(&$form_state, $status, $step) {
 
// Write your own conditions
 
switch ($step) {
    case
1:
     
// if some condition
       
$status = 'submitted';
     
// else
       
$status = 'unsubmitted';
      break;
    case
2:
     
// etc...
 
}
  return
$status;
}
?>

Where hook is the name of your module. This will allow you to set the $step of the node to the specificed $status at the time of submission. It should return the string of the status: the options are 'submitted' or 'unsubmitted'.

 
 

Drupal is a registered trademark of Dries Buytaert.