Closed (fixed)
Project:
Multistep (D7)
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
6 May 2010 at 15:02 UTC
Updated:
17 Mar 2012 at 06:59 UTC
Hello,
I'm using this module for a central feature on one of my projects and am very satisfied with it. I did everything I wanted to until now.
I need to create a button to save the form and then go to the last step. To achieve this, I put the following code in mymodule_form_alter :
$form['buttons']['last'] = array(
'#type' => 'submit',
'#value' => 'Save and go to last step',
'#submit' => array('last_step'),
'#weight' => -1000,
);Whatever I tried, a click on this button always triggers the behaviour of another button, most frequently the 'delete' one.
I guess it has to do with something I don't understand in the form API, but I can't guess what.
I would greatly appreciate any bit of information.
Thanks
Comments
Comment #1
vkareh commentedI'm interested in seeing what the code looks like for your
function last_step().A while ago I did something similar for a client. At that time, the way the multistep module was designed, I could not find a better way than adding this to the submit function:
It's not very elegant, but it worked. It makes me think that there should be a
hook_multistep_set_next_step()or something like that in this module.Comment #2
Countzero commentedHello,
I solved my issue in the meantime and forgot to update, sorry.
My function didn't work because form_alter was called twice when the form was submitted, so I had to test where I was in the submit process otherwise the form began to behave strangely.
My last_step function is a rewrite of next_step included in the module :
And I had to test the context in hook_form_alter:
The 'from' variable was added to the URL to 'remember' how I got there. I guess I could have used the 'destination' parameter, but was afraid of interfering with something else and was urged.
Not very beautiful code if you ask me, but it works.
Comment #3
vkareh commentedAwesome! I'm glad you solved it.
Still, I think a
hook_multistep_set_next_step()would be very valuable for users in this situation. I'll mark this as a feature request for the development version.Comment #4
Countzero commentedIt's clear it would have simplified my life for a while ;-).
My solution lacks a tight integration with the logic of your code, because I didn't have time to study it for long. For this kind of problems it's clear the hook would somewhat 'force' developpers to adhere more closely to the internal logic of the module, which may or may not be a good thing.
Anyway, it scaled good enough to at least allow an unexpected behaviour, which not every module does.
Again, thanks for your work.
Comment #5
vkareh commentedAdded
hook_multistep_set_step()to the latest development snapshot. Here's the documentation with an example:Comment #7
roball commentedThis new hook is working fine, thanks! Exactly what I needed for one project.
Do you think this wiill go into 6.x-1.6 anytime soon?
Comment #8
fnikola commentedhow does this hook get exectured?
Comment #9
roball commentedIn your own module MY_MODULE, implement the hook_multistep_set_step(), like this:
Comment #10
roball commented@fnikola: Did you try that?