limit_validation_errors resetting form values in submit handler I have a custom button in my form_alter and a submit handler for that . I don't need validation for this button submit . I tried by giving limit_validation_errors to exclude all validation for the custom submission . When giving like this am not receiving any form values in submit handler . Any idea on how to resolve this issue ?  

TRY

function mymodule_form_alter(&amp;$form, FormStateInterface $form_state, $form_id){
 //Additional button for the Save as Draft feature
  $form['actions']['draftsubmit'] = array(
      '#type' =&gt; 'submit',
      '#value' =&gt; t('Save as Draft'),
      '#weight' =&gt; 1000,
      '#submit' =&gt; array('draft_form_submit'),
      '#limit_validation_errors' =&gt; array(),                       
     );              
}


/**
 * Handles the save as draft button submit 
 */
function draft_form_submit($form, &amp;$form_state) {
    echo '&lt;pre&gt;';print_r($form_state-&gt;getValues());exit;echo '&lt;/pre&gt;'; //Not getting values here 
    $name = $form_state-&gt;getValue('field_p_name')[0]['value'];
    $dc = $form_state-&gt;getValue('field_p_dc')[0]['value'];
    $sec_type = $form_state-&gt;getValue('field_p_sec_type')[0]['value'];
}


UPDATE



I have other validations in other modules form_alter like

 function othermodule_form_alter(&amp;$form, FormStateInterface $form_state, $form_id){
    $form['field_fwd_acl']['#element_validate'] = array('validate_IpAndNetworks');
    $form['field_fwd_dest_acl']['#element_validate'] = array('field_fqdn_validate');
    $form['field_amount_of_proxies']['#element_validate'] = array('field_instance_validate');
}


I mean these validations should not be worked when clicked on Save as Draft button is clicked
#limit_validation_errors prevents values from being passed to the submit handler, since they have not been validated. You can whitelist values by passing the form element key to #limit_validation_errors:

'#limit_validation_errors' =&gt; [
  // format follows the same as in the form state values. Elements
  // that are not #tree will be a string. Nested elements will be
  // an array.
  'element1',
  ['wrapper','element2'],
];


If you want to limit validation, but need all the values in the submit handler, then it's better to not use #limit_validation_errors. Instead, you can wrap any validation in a conditional to check if the 'next' button was clicked:

if ($form_state-&gt;getTriggeringElement() == $form['actions']['next']) {
  // Do form validation here. If the 'back' button was clicked, this
  // validation code will not be clicked. It will only be validated if
  // next has been clicked.
}


Note that if you use #required, validation will still happen even with the above code, since #required is handled separately. In this case, I don't use #required, instead I'll add custom validation to the above code:

if ($form_state-&gt;getTriggeringElement() == $form['actions']['next']) {
  // Do form validation here. If the 'back' button was clicked, this
  // validation code will not be clicked. It will only be validated if
  // next has been clicked.
  if (!strlen($form_state-&gt;getValue('some_element')) {
    $form_state-&gt;setError('some_element', $this-&gt;t('Please fill in a value for some field'));
  }
}