I am using the ctools wizard component and these are 2 "issues" i have ran into. I found some workarounds and thought it would be helpful to include them in the advanced help :
1 - Back button and validation
Some brieg information is included on advanced help but you might want to include a workaround :
To avoid having drupal trying to Validate a form when the user clicks the back button, include the following at the top of you form validation function :
if ($form_state['clicked_button']['#wizard type'] == 'cancel') {
// Clear the error messages.
drupal_get_messages('error');
// Clear the form error state (the required fileds errors).
form_set_error(NULL, '', true);
return TRUE;
}
2 - Wizard for anonymous users
If you are creating a wizard that would be used by anonymous users, you might run it to some issues with page caching for anonymous users. You can circumvent this issue by using hook_init and telling drupal to never cache your wizard pages :
function mymodule_init() {
// if the path leads to the wizard
if (drupal_match_path($_GET['q'],'path/to/my/wizard/*')) {
// set cache to false
$GLOBALS['conf']['cache'] = FALSE;
}
}
Comment | File | Size | Author |
---|---|---|---|
#3 | ctools-help-wizard.patch | 1.63 KB | redben |
Comments
Comment #1
ayalon CreditAttribution: ayalon commentedHey renben!
Thanks for this post. I was googling for exactly this bug fixes. I think everyone coding a wizard using ctools will come accross these problems and your post is very helpful an clear!
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedIt would facilitate adoption of this if you could provide a patch to the advanced help file. =)
Comment #3
redben CreditAttribution: redben commentedSorry :) here is a patch
BTW i changed the code example for validation to handle anything that's not what should be next :
Comment #4
redben CreditAttribution: redben commentedComment #5
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted to D6. Thanks for the patch!
Comment #6
merlinofchaos CreditAttribution: merlinofchaos commentedAll of the 'to be ported' patches got merged in during the porting sprint in September.