By pwhite on
Hi,
I have a form that has two buttons, one for next and one for previous - how do I detect which has been clicked?
Form function
$form['previous'] = array(
'#type' => 'submit',
'#value' => t('Previous'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Next'),
);
Submit Function
if($form_state['#submit']['previous'])
drupal_goto("signup/1");
else
drupal_goto("signup/3");
Many thanks
Comments
Just if it helps anyone I
Just if it helps anyone I added a #validate into the first button:
That called the function signup_form_previous with a drupal_goto function in.
found your answer by dumping
found your answer by dumping $form variable on hook form validate. there's an op object that show you which submit triggered.
Use #submit
Use the '#submit' value to specify a dedicated form submit handler for each button.
solution?
Does anyone have a solution to this?
if($form_state['values']['op'
Contact me to contract me for D7 -> D10/11 migrations.
Use '#submit'
See my suggestion above.