After a lot of searching I found out that submit callbacks can only be attached to both forms and form fields of the type 'button', and not to other form elements. I think it is wise to mention this in the API documentation of hook_elements. Now it tells us simply that #submit can be used, while actually it can only be used if the form element is a button.

#344233: #submit callback in hook_elements

Comments

jhodgdon’s picture

Version: 6.x-dev » 7.x-dev

Not only that, but only the #submit handler for the button that is clicked to submit the form will actually be executed, not all possible #submit functions.

This should be mentioned in the Drupal 6 hook_elements() doc and the Drupal 7 hook_element_info() doc
http://api.drupal.org/api/function/hook_elements/6
http://api.drupal.org/api/function/hook_element_info/7