I have a form in which I have added a cancel button which looks like this:
$form['cancel_button'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#name' => 'cancel',
'#access' => TRUE,
'#submit' => array('mymodule_cancel'),
'#limit_validation_errors' => 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'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.