// In submit function of a form, mark it for rebuild public function myFormSubmit(array &$form, FormStateInterface $form_state){ $form_state->setRebuild(); }
// In validate function of a form, mark it for rebuild if validation fails public function myFormValidate(array &$form, FormStateInterface $form_state){ $value = $form_state->getValue('my_field'); if(empty($value)){ $form_state->setRebuild(); } }In this example, the form is marked for rebuild if the validation of a specific field fails. This can be used to ensure that the user provides a certain input before proceeding. This feature is part of Drupal's core form API and does not require any external package or library.