Edit: A closer check of the Forms API Documentation revealed that my initial answer below is valid for Drupal 6, but only partially valid for Drupal 5. Comparing the Drupal 5 docs with the Drupal 6 docs shows that in Drupal 5, you can only register callback functions on the form itself - the '#submit' property of a button is just a boolean indicating that the button is to be handled as a submit button. So adding 'per button' callbacks is a Drupal 6 only feature!
For the given Question, this means that there is only the if/elseif option suggested by ax, or the variation of registering two submit callbacks for the form, each checking if they are called for the right button (basically the if/elseif version, but using two separate callbacks).
(initial answer)
There are several mechanisms at work here:
- Submit (and validate) callbacks can be registered for individual buttons, but also for the form itself (
$form['#submit']
). The ones registered for the form get called for every submit button, the ones registered for an individual button only for that one. (NOTE: Important Drupal 5/6 difference here, see edit below.)
- The default form handling (submit and validate functions named after the form) works by Drupal automatically adding callbacks for those to the forms
'#submit'
and '#validate'
arrays.
- The registration uses arrays in order to allow for several submit/validate functions being called one after the other (in the same order they appear in the array).
So in your case, you could do the if/elseif switch suggested by ax, or you'd need to unset the 'global' callbacks for the form, moving it explicitly to the default submit button:
$form['fieldset']['submit']['#submit'] = $form['#submit'];
unset($form['#submit'];
(same thing for validate callbacks)
After that, your posted example for the Big Red Button executing the evil plan should work as expected ;)