// calls to \Drupal\Core\Form\FormStateInterface::setErrorByName() be
// suppressed and not result in a form error, so that a button that
// implements low-risk functionality (such as "Previous" or "Add more") that
// doesn't require all user input to be valid can still have its submit
// handlers triggered. The triggering element's #limit_validation_errors
// property contains the information for which errors are needed, and all
// other errors are to be suppressed. The #limit_validation_errors property
// is ignored if submit handlers will run, but the element doesn't have a
// #submit property, because it's too large a security risk to have any
// invalid user input when executing form-level submit handlers.
$triggering_element =
$form_state->
getTriggeringElement();
if (isset($triggering_element['#limit_validation_errors'
]) && ($triggering_element['#limit_validation_errors'
] !== FALSE
) && !
($form_state->
isSubmitted() && !
isset($triggering_element['#submit'
]))) { return $triggering_element['#limit_validation_errors'
];
} // If submit handlers won't run (due to the submission having been
// triggered by an element whose #executes_submit_callback property isn't
// TRUE), then it's safe to suppress all validation errors, and we do so
// by default, which is particularly useful during an Ajax submission
// triggered by a non-button. An element can override this default by
// setting the #limit_validation_errors property. For button element
// types, #limit_validation_errors defaults to FALSE, so that full
// validation is their default behavior.
elseif ($triggering_element && !
isset($triggering_element['#limit_validation_errors'
]) && !
$form_state->
isSubmitted()) {