On a Drupal 7 Webform I've added a button using a markup field like this:

<button name="get" value="" type="submit" class="primary-submit submit" id="get">
Get Address

I am directing it to a submit handler like this:

function new_webform_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'webform_client_form_88') {

I can tell the button #submit is being changed, but the whole form is submitted instead of executing the handler code. What am I doing wrong?

  • I think you forgot your code snippets =\
    – Chapabu
    Commented Apr 6, 2012 at 15:30

2 Answers 2


Turns out the form was not actually being submitted but the custom handler was not being processed because the form validation was failing. I disabled it with


and now the handler works.


In a general scenario, to add a custom submit handler to any Drupal form you can implement hook_form_alter or hook_form_form_id_alter

you will have to add the submit handler in the #submit array, something like this,

$form['#submit'][] = 'my_custom_submit_handler'; //this function will accept $form and $form_state as args.

same can be done for #validate if you want a extra validate handler.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.