I would like to performa a 3 step for my registration page.

I add some fields with profile module, now how I can assign this fields to three different step...?
I found this piece of code for make multi-step for drupal 6 but I don't understand how do that (assign profile fields to this code, and where I save this code .. )

 <?php
function formDemo_node() {
  $items['registration/form'] = array(
    'title' => t('My form'),
    'page callback' => 'formDemo_form',
    'access arguments' => array('access content'),
    'description' => t('My form'),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function formDemo_form() {
    return drupal_get_form('formDemo_my_form');
}

//helper function that isn't needed, but I thought it was needer
function formDemo_dv($setValue, $default='') {
    return ($setValue===null)?$default:$setValue;
}

function formDemo_my_form($form_state) {

    if (empty($form_state['storage']['step'])) {
        // we are coming in without a step, so default to step 1
        $form_state['storage']['step'] = 1;
    }
    
    //demo different fields on different steps
    switch ($form_state['storage']['step']) {
        case 1:
          $form['field1'] = array (
            '#type' => 'textfield',
            '#default_value' => formDemo_dv($form_state['storage']['values'][1]['field1']),
            '#title' => t('Test Field'));    
          break;
        case 2:
         $form['field2'] = array (
            '#type' => 'textfield',
            '#default_value' => formDemo_dv($form_state['storage']['values'][2]['field2']),
            '#title' => t('Test Field 2'));
          break;
        case 3:
         $form['field3'] = array (
            '#type' => 'textfield',
            '#default_value' => formDemo_dv($form_state['storage']['values'][3]['field3']),
            '#title' => t('Test Field 3'));
          break;
        default:
            ///blah blah, really you should never get here
          break;
    }
    
    //don't show back button on first tab
    if ($form_state['storage']['step'] > 1) {
        $form['previous'] = array(
            '#type' => 'submit',
            '#value' => '<< Previous'
          );
    }
    
    //show next button all the time in this demo
    $form['next'] = array(
        '#type' => 'submit',
        '#value' => 'Next >>'
      );
    return $form;
}


function formDemo_my_form_submit($form, &$form_state) {
    //save the values for the current step into the storage array
    $form_state['storage']['values'][$form_state['storage']['step']] = $form_state['values'];
    
    // check the button that was clicked and action the step chagne
    if ($form_state['clicked_button']['#id']=='edit-previous') {
        $form_state['storage']['step']--;
    } elseif ($form_state['clicked_button']['#id']=='edit-next') {
        $form_state['storage']['step']++;
    }
    
    //tell Drupal we are redrawing the same form
    $form_state['rebuild'] = TRUE;
    
}

Comments

Aquilasfx’s picture

help please... :(

maulwuff’s picture

this might be of help for you
http://api.drupal.org/api/search/6/multistep

auctionteamster’s picture

Did you figure it out -- working on similar issue.

operations’s picture

me too