$form_state->
setCached();
} // \Drupal\Component\Utility\Html::getUniqueId() maintains a cache of
// element IDs it has seen, so it can prevent duplicates. We want to be
// sure we reset that cache when a form is processed, so scenarios that
// result in the form being built behind the scenes and again for the
// browser don't increment all the element IDs needlessly.
if (!FormState::
hasAnyErrors()) { // We only reset HTML ID's when there are no validation errors as this can
// cause ID collisions with other forms on the page otherwise.
Html::
resetSeenIds();
} // If only parts of the form will be returned to the browser (e.g., Ajax or
// RIA clients), or if the form already had a new build ID regenerated when
// it was retrieved from the form cache, reuse the existing #build_id.
// Otherwise, a new #build_id is generated, to not clobber the previous
// build's data in the form cache; also allowing the user to go back to an
// earlier build, make changes, and re-submit.
// @see self::prepareForm()
$rebuild_info =
$form_state->
getRebuildInfo();
$enforce_old_build_id =
isset($old_form['#build_id'
]) && !
empty($rebuild_info['copy'
]['#build_id'
]);