To reproduce:

  1. Enable ctools_ajax_sample.module
  2. Navigate to /ctools_ajax_sample
  3. Click on any of the wizard links that involve a modal - eg "Wizard (default modal)"
  4. Make an animal selection, and click "Continue"
  5. Now click "Back" (make any required radio selections first to avoid core bug http://drupal.org/node/811542)
  6. You will now be at the first pane of the form again, but there will be a "Back" button where there should be none.
  7. You can now click the back button over and over again, looping through the form infinitely.

This bug does not occur if you click on the "Wizard (no modal)" link.

I'm just in the process of trying to figure out ctools, so I'm not sure if this is a bug in ctools, or a bug in the example, but getting it fixed would very much help advance my understanding of the module :) .

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JordanMagnuson’s picture

Issue summary: View changes

Made some text bold.

yogeshchaugule8’s picture

Issue summary: View changes

Hi JordanMagnuson, did you found solution for this issue, I'm facing the same issue.

I'm using 7.x-1.3 version of ctools.

JordanMagnuson’s picture

No, sorry, didn't ever solve this.

adriankremer’s picture

i just found that the "$not_first" var in "includes/wizard.inc" seems to be unused and can be used as condition in creating the previous button.

$not_first = FALSE; (line: 237)

elseif ($previous) {
 --> $not_first = TRUE; (line: 246)
      $class = 'wizard-trail-previous';
      $form_state['previous'] = $id;
    }

if (!empty($form_info['show back']) && isset($form_state['previous']) ### && $not_first == true ###) { (line: 297: without hashtags)

greetings adrian

sumthief’s picture

Status: Active » Needs review
FileSize
722 bytes

Hello

Faced with the same problem on my current project.

There is one of variants to solve this problem in #3.

But I think we shouldn't modify ctools_wizard_wrapper function for this.
Condition to add 'Back' button is very simple:

!empty($form_info['show back']) && isset($form_state['previous'])

Also we have some manipulations with $previous variable some lines above.

Looks like the root of the problem is that passed $form_state for showing next step is built from previous step.

So I think we should unset it before new step was shown.

Here is a patch which solves this problem.

sumthief’s picture

Status: Needs review » Closed (duplicate)

There is an older issue which describes exactly same problem.
Here is a link - https://www.drupal.org/node/1488930.

Rushikumar’s picture

@sumthief
Can confirm the patch in #4 fixes the issue.

My versions--
Drupal v7.52
ctools - 7.x-1.9