How to implement a cancel button with required elements I have a form in which I have added a cancel button which looks like this:

$form['cancel_button'] = array(
  '#type' =&gt; 'submit',
  '#value' =&gt; t('Cancel'),
  '#name' =&gt; 'cancel',
  '#access' =&gt; TRUE,
  '#submit' =&gt; array('mymodule_cancel'),
  '#limit_validation_errors' =&gt; array(),
);


This form has required elements in it as well and what is causing the problem. I thought that by having the #limit_validation_errors statement would prevent the required elements check, but that is not happening. How do I prevent the required elements from being checked?

EDIT: I found this answer on a different question Isn&#39;t it possible to have multiple buttons  along with a submit button? 

This would explain the behaviour I am seeing but it seems to contradict the Drupal documentation about limiting error checking. This would really screw up people who want to save a draft of a form that has required fields. I am pretty sure I have seen this done before, so there must be away around this.
You can make something like this in your function validate : 

function FORM_validate(&amp;$form, &amp;$form_state) {
if ($form_state['values']['op'] == 'cancel')
{
 ///  Do something
/// drupal_goto() for example
}
}