The back button (which name is 'previous') has a '#wizard type' set to 'next' (line 244 of wizard.inc) :
$form['buttons']['previous'] = array(
'#type' => 'submit',
'#value' => $form_info['back text'],
'#next' => $form_state['previous'],
'#wizard type' => 'next',
'#weight' => -2000,
'#skip validation' => TRUE,
// hardcode the submit so that it doesn't try to save data.
'#submit' => array('ctools_wizard_submit'),
'#attributes' => $button_attributes,
);
So I think the 'back callback' will never be called.
The only way I found to "overload" the 'back callback' property is (line 442 of wizard.inc) :
// set button callbacks
$callbacks = array(
'back callback' => '_back',
'next callback' => '_next',
'return callback' => '_return',
'cancel callback' => '_cancel',
'finish callback' => '_finish',
);
foreach($callbacks as $key => $callback) {
// never overwrite if explicity defined
if (empty($form_info[$key])) {
$wizard_callback = $hook . $callback;
if (function_exists($wizard_callback)) {
$form_info[$key] = $wizard_callback;
}
}
}
Where the $hook variable comes from the $form_info (line 414 of wizard.inc) :
$hook = $form_info['id'];
Which is hardcoded to 'ctools_content_form' (line 558 of content.inc) :
$form_info += array(
'id' => 'ctools_content_form',
'show back' => TRUE,
);
Comments
Comment #1
dimduj commentedHi,
I'm facing the same issue...
It seems that when you use a wizzard in a Ctools content type you couldn't override the "next callback" *.
(* "cancel callback" is never used in wizzard, see http://drupal.org/node/749362)
This is because, in the ctools_content_form(), when we set an array for the "edit/add form"** in the $plugin of our content type, we only pass $subtype['edit form'] to the _ctools_content_create_form_info() and we have no other chances to provide a $form_info['next callback'] with a correct and custom value before calling ctools_wizard_multistep_form()...
** An array for 'edit form' or 'add form' => we want a wizzard for the content type
content.inc line 572
If somebody has an idea , he 's welcome !
Maybe I can try to provide a patch for that but I would like to have some guildeline/advice from a maintener ...
Comment #2
b-prod commentedDoes it trouble anybody to tag this issue as 7.x, since there is the main issue in this version of cTools wizard? If the bug is fixed for the 7.x, which is the current active version, I could easily add a backport for D6.
For a quick workaround, you can check if the
'next'key exists in$form_statearray. If not, the'previous'key should exist. Like that you can easily know which kind of action to perform. Maybe it could be better to rename the'next callback'key but I am afraid that it needs everybody who uses cTools wizard to update his code... almost bad!I just said it was a quick workaround, but it could be the way for cTools wizard to work. So the
'back callback'key could be totally removed from the code and documentation, and there would be only one callback function to handle 'next' and 'back' behavior.@maintainers: tell me if you agree with that, so I could post a patch that fixes this stuff. Otherwise, if you prefer to have a separate callback, you just have to apply the provided patch.
Comment #3
b-prod commentedHmmm I renamed the wrong patch file, sorry.
Here is the correct one.
Comment #4
tim.plunkettThere are a large number of references to 'next' throughout other parts of CTools.
I haven't tried this, but have you looked at the code to ensure no further changes are needed?
Comment #5
b-prod commentedIf I remember well, the other are related to AJAX calls. I didn't change those parts because I have currently no way to test them.
Comment #6
b-prod commentedTime has passed... and the patch does not apply anymore to the current cTools release. No time to investigate on what changed in wizard and how to process.
There is still something to fix there, so I changed the issue as a feature request, if somebody in the future will work on that.
Comment #7
abratko commentedI Have this issue in 7.x-1.3 version
Thanks for patch.
Comment #8
abratko commentedComment #9
abratko commentedComment #10
intrafusionI am encountering this problem, but found a workaround:
I would prefer not to use the if statement, but this provides a workaround as my MODULE_back(&$form_state) is never called
Comment #11
japerryDrupal 7 is no longer supported, closing.