Isn't it possible to have multiple buttons  along with a submit button? I have a simple Drupal 7 form, with 3 dropdown select lists and a submission button. I want to add another button to the form which does some function (but not submitting the form). I want to bypass the validation part for the form and directly run the submission handler of that button.

The button I am using is the following one.

$form['my_fieldset']['click'] = array(
  '#type' =&gt; 'button',
  '#value' =&gt; 'click me',
  '#limit_validation_errors' =&gt; array(),
  '#executes_submit_callback' =&gt; FALSE,
  '#submit' =&gt; array('my_module_click_submit'),
);


FYI, all the select lists have #required=&gt;TRUE, and #type=&gt;'submit' for the button also doesn't work.

When I click it, it shows the error about the fields being required. How can I avoid that error, avoid validation handlers are run, and just run the code in my_module_click_submit()?  

Also, I dont know why, but even if I fill the entire form and then click this button, the page just gets refreshed and my_module_click_submit() does NOT run. What's wrong?

I haven't put anything fancy inside my_module_click_submit(); I just wanted to see if it works. The submission handler I am trying is the following one.

function my_module_click_submit($form,&amp;$form_state) {
  drupal_set_message('Click me button is clicked');
}
Jaypan gave me the answer.


  
  Required checks happen irregardless of validation - they happen before any other validation even occurs.
  You cannot skip the default _validation() function, it is always executed
  When you choose limit_validation_errors(), anything that is not part of that array is not submitted.
  
  
  As such, you will want to explicitly declare your submit and validate functions for the original submit button, and leave the second button as-is, using the default submit and validate functions:

function some_form($form, &amp;$form_state) {
  // Form definition not shown.
  $form['submit1'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Submit 1'),
    '#validate' =&gt; array('my_explicit_validate'),
    '#submit' =&gt; array('my_explicit_submit'),
  );

  $form['submit2'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Submit 2'),
  );

  return $form;
}

// my_form_validate is not created, since we don't want to validate the second submit button, but we do want the submit function.
function my_form_submit($form, &amp;$form_state) {
  // You need to check which submit button was pushed, as this function
  // will be run for both buttons, but you only want do something if it was the 
  // secondbutton.
  if($form_state['values']['op'] == $form_state['values']['submit2']) {
    // Second submit button's submit function.
  }
}

function my_explicit_validate($form, &amp;$form_state) {
  // Validation for the first submit button.
}

function my_explicit_submit($form, &amp;$form_state) {
  // First submit button's submit function.
}

  
  To deal with your required issue, you will need to not set #required =&gt; TRUE for the elements, and check them manually in your validation function (the function explicitly declared for the first button). If you want to have the required marks, I think you can manually add them to the element title, or you can override the theme function for those elements and manually add them there.