1 form_example_wizard.inc form_example_wizard_next_submit($form, &$form_state)

Submit handler for the 'next' button.

This function:

  • Saves away $form_state['values']
  • Increments the step count.
  • Replace $form_state['values'] from the last time we were at this page or with array() if we haven't been here before.
  • Force form rebuild.

You are not required to change this function.

Related topics

File

modules/examples/form_example/form_example_wizard.inc, line 180
Extensible wizard form example.

Code

function form_example_wizard_next_submit($form, &$form_state) {
  $current_step = &$form_state['step'];
  $form_state['step_information'][$current_step]['stored_values'] = $form_state['values'];

  if ($current_step < count($form_state['step_information'])) {
    $current_step++;
    if (!empty($form_state['step_information'][$current_step]['stored_values'])) {
      $form_state['values'] = $form_state['step_information'][$current_step]['stored_values'];
    }
    else {
      $form_state['values'] = array();
    }
    // Force rebuild with next step.
    $form_state['rebuild'] = TRUE;
    return;
  }
}