public function FormSubmitter::doSubmitForm in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Form/FormSubmitter.php \Drupal\Core\Form\FormSubmitter::doSubmitForm()
- 9 core/lib/Drupal/Core/Form/FormSubmitter.php \Drupal\Core\Form\FormSubmitter::doSubmitForm()
File
- core/
lib/ Drupal/ Core/ Form/ FormSubmitter.php, line 46
Class
- FormSubmitter
- Provides submission processing for forms.
Namespace
Drupal\Core\FormCode
public function doSubmitForm(&$form, FormStateInterface &$form_state) {
if (!$form_state
->isSubmitted()) {
return;
}
// Execute form submit handlers.
$this
->executeSubmitHandlers($form, $form_state);
// If batches were set in the submit handlers, we process them now,
// possibly ending execution. We make sure we do not react to the batch
// that is already being processed (if a batch operation performs a
// \Drupal\Core\Form\FormBuilderInterface::submitForm).
if (($batch =& $this
->batchGet()) && !isset($batch['current_set'])) {
// Store $form_state information in the batch definition.
$batch['form_state'] = $form_state;
$batch['progressive'] = !$form_state
->isProgrammed();
$response = batch_process();
// If the batch has been completed and _batch_finished() called then
// $batch will be NULL.
if ($batch && $batch['progressive']) {
return $response;
}
// Execution continues only for programmatic forms.
// For 'regular' forms, we get redirected to the batch processing
// page. Form redirection will be handled in _batch_finished(),
// after the batch is processed.
}
// Set a flag to indicate the form has been processed and executed.
$form_state
->setExecuted();
// If no response has been set, process the form redirect.
if (!$form_state
->getResponse() && ($redirect = $this
->redirectForm($form_state))) {
$form_state
->setResponse($redirect);
}
// If there is a response was set, return it instead of continuing.
if (($response = $form_state
->getResponse()) && $response instanceof Response) {
return $response;
}
}