You are here

function ctools_wizard_submit in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/wizard.inc \ctools_wizard_submit()

On a submit, go to the next form.

1 string reference to 'ctools_wizard_submit'
ctools_wizard_wrapper in includes/wizard.inc
Provide a wrapper around another form for adding multi-step information.

File

includes/wizard.inc, line 415
CTools' multi-step form wizard tool.

Code

function ctools_wizard_submit(&$form, &$form_state) {
  if (isset($form_state['clicked_button']['#wizard type'])) {
    $type = $form_state['clicked_button']['#wizard type'];

    // If AJAX enabled, we proceed slightly differently here.
    if (!empty($form_state['ajax'])) {
      if ($type == 'next') {
        $form_state['ajax next'] = $form_state['clicked_button']['#next'];
      }
    }
    else {
      if ($type == 'cancel' && isset($form_state['form_info']['cancel path'])) {
        $form_state['redirect'] = $form_state['form_info']['cancel path'];
      }
      elseif ($type == 'next') {
        $form_state['redirect'] = ctools_wizard_get_path($form_state['form_info'], $form_state['clicked_button']['#next']);
        if (!empty($_GET['destination'])) {

          // We don't want drupal_goto redirect this request
          // back. ctools_wizard_get_path ensures that the destination is
          // carried over on subsequent pages.
          unset($_GET['destination']);
        }
      }
      elseif (isset($form_state['form_info']['return path'])) {
        $form_state['redirect'] = $form_state['form_info']['return path'];
      }
      elseif ($type == 'finish' && isset($form_state['form_info']['cancel path'])) {
        $form_state['redirect'] = $form_state['form_info']['cancel path'];
      }
    }
  }
}