Create multiple step form in Drupal 6

5 Comments

Multiple step form which consists of multiple steps or pages is useful sometimes. It allows you to create a form workflow and helps to make your web site user-friendly and flexible. For example, you can make different contents on next pages based on user inputs from previous pages.

The key things to make a form multiple pages are setting $form_state[‘rebuild’] and $form_state[‘storage’] variables in a submit function.

 

function example_form_submit($form, &$form_state) {

  if($form_state['storage']['page'] == 1) {

    $form_state[‘rebuild’] = TRUE;

    $form_state[‘storage’][$page][‘values’] = $form_state[‘values’];

    $form_state['storage']['page']++;

  else {

     //process the data

  }

}

 

Breadcrumbs and path aliasing

1 Comment

I came across a problem with Drupal's breadcrumbs not working properly with path aliasing. For instance, you're in the 'about' section...then you go to a sub-page of that section and the url says 'about/people'. What this friendly url actually means though is node/8. So if I'm creating page nodes and aliasing them to 'about/contact' and 'about/services', it's deceiving because these paths really don't have any sort of relationship to one another, other than a visual one created by the path aliasing. Drupal's breadcrumb isn't smart enough to interpret all these paths as being related, inside the 'about' section so I had to make some modifications.

In template.php: