[development] Forms API and multiple submit buttons
Syscrusher
syscrusher at 4th.com
Mon Nov 20 04:06:45 UTC 2006
Okay, I've looked in the docs and at some of the Drupal core modules, but I
haven't been able to get this to work.
I need to have a Drupal 4.7/5.0 form that has multiple submit buttons. I want
each button to invoke the hook_validate() and hook_submit() functions, but I
need a way to determine which button was the one actually pressed.
Code like this is what I initially tried in my form:
$form = array(
.... stuff ....
'button1' => array(
'#type' => 'submit',
'#value' => t('Foo'),
),
'button2' => array(
'#type' => 'submit',
'#value' => t('Bar'),
),
);
Now, both buttons work, but the form values array has both of their values.
I tried using #default_value and #return_value instead of #value, but it seems
not to change anything.
Is there a better way to do this?
Thanks!
Scott (Syscrusher)
--
-------------------------------------------------------------------------------
Syscrusher (Scott Courtney) Drupal page: http://drupal.org/user/9184
syscrusher at 4th dot com Home page: http://4th.com/
More information about the development
mailing list