I have been following the steps of this tutorial:
Tutorial: Ten Step-by-Step Code Samples to Help You Quickly Learn Form API

In order to do a multistepped form module, now in the tutorial it allow this form to show two pages. Now my question is, how do I get it to make a third? This is what I have created so far, but when I click the Next button on page two it will just clear the values on page two and remain there.

<?php
function client_wizard_my_form_page_three() {
  $form['client'] = array(
  '#type' => 'fieldset',
  '#title' => t(details'),
  '#collapsible' => TRUE,
  '#collapsed' => FALSE,
  
  );
    $form['client']['cname'] = array(
    '#type' => 'textfield',
    '#title' => t('Client name'),
    '#default_value' => $form_state['values']['cname'], // changed
    '#description' => "Please enter the name of the client.",
    '#size' => 20,
    '#maxlength' => 30,
    '#required' => TRUE,
  );

  $form['client']['url'] = array(
     '#type' => 'textfield',
      '#title' => t('Url'),
      '#description' => "Please enter the clients URL.",
      '#size' => 20,
      '#maxlength' => 30,
      '#default_value' => $form_state['values']['url'],
  );
    $form['client']['lang'] = array(
    '#type' => 'select',
    '#title' => t('Select language'),
    '#default_value' => $form_state['values']['lang'],
    '#options' => array(
    0 => 'SV',
    1 => 'FI',
    2 => 'DK',
    3 => 'NO',
    ),
    '#description' => t('Select the language that this client is using'),
  );
     $form['client']['nicks'] = array(
     '#type' => 'textfield',
      '#title' => t('Nicks'),
      '#default_value' => $form_state['values']['nicks'],
  );
     
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
  );


  return $form;
}
function client_wizard_my_form_submit($form, &$form_state) {

  // Handle page 1 submissions
  if ($form_state['clicked_button']['#value'] == 'Next One') {
    $form_state['storage']['page_two'] = TRUE; // We set this to determine
                                               // which elements to display
                                               // when the page reloads.
                                              
    // We save our values below in the $form_state['storage'] array so they
    // will carry forward to subsequent pages in the form.
    $form_state['storage']['page_one_values'] = $form_state['values'];
  }

  // Handle page 3 submissions
  elseif ($form_state['clicked_button']['#value'] == 'Next Two') {
    $form_state['storage']['page_three'] = TRUE; // We set this to determine
                                               // which elements to display
                                               // when the page reloads.
                                              

    $form_state['storage']['page_two_values'] = $form_state['values'];
    
  }
  else {

    drupal_set_message('Your form has been submitted');
    unset ($form_state['storage']); // This value must be unset or we will
                                    // not be redirected! This is because
                                    // $form_state['rebuild'] gets set to TRUE
                                    // when 'storage' is set. See code sample
                                    // #9 for more on this.
                                   
    $form_state['redirect'] = 'node'; // Here's how we redirect the user.
  }
}
?>

Comments

Cayhn’s picture

Nevermind I just figured it out :p

radhika.w’s picture

hi there...
i wanted to know a way for handling multiple submit buttons and their click events..
here i have a form where i have two buttons ... search and save...
When the user clicks on search, the page is redirected to myform/search
and else, myform/save ...
I have been trying to use the condition:

<?php
if($form_state['values']['search'] == 'Search'){
$form_state['redirect'] = 'myform/search/'.$form_state['values']['compname'];
}
$form_state['redirect'] = 'myform/save/'.$form_state['values']['compname'].'/'.$form_state['values']['street'].'/'.$form_state['values']['locality'].'/'.$form_state['values']['city'].'/'.$form_state['values']['pin'].'/'.$form_state['values']['state'].'/'.$form_state['values']['country'].'/'.$form_state['values']['description'].'/'.$form_state['values']['headedby'].'/'.$form_state['values']['contactperson'].'/'.$form_state['values']['phone'].'/'.$form_state['values']['email'].'/'.$form_state['values']['website'].'/'.$form_state['values']['branch'].'/'.$form_state['values']['category'];

}
?>

This jus doesnt go in the if loop and runs out and redirects to the myform/save page ...

Can you help?!?!

Thnaks,
Radhika