function FormSubmitter::executeSubmitHandlers

Same name in other branches
  1. 9 core/lib/Drupal/Core/Form/FormSubmitter.php \Drupal\Core\Form\FormSubmitter::executeSubmitHandlers()
  2. 8.9.x core/lib/Drupal/Core/Form/FormSubmitter.php \Drupal\Core\Form\FormSubmitter::executeSubmitHandlers()
  3. 11.x core/lib/Drupal/Core/Form/FormSubmitter.php \Drupal\Core\Form\FormSubmitter::executeSubmitHandlers()
1 call to FormSubmitter::executeSubmitHandlers()
FormSubmitter::doSubmitForm in core/lib/Drupal/Core/Form/FormSubmitter.php

File

core/lib/Drupal/Core/Form/FormSubmitter.php, line 108

Class

FormSubmitter
Provides submission processing for forms.

Namespace

Drupal\Core\Form

Code

public function executeSubmitHandlers(&$form, FormStateInterface &$form_state) {
    // If there was a button pressed, use its handlers.
    $handlers = $form_state->getSubmitHandlers();
    // Otherwise, check for a form-level handler.
    if (!$handlers && !empty($form['#submit'])) {
        $handlers = $form['#submit'];
    }
    foreach ($handlers as $callback) {
        // Check if a previous _submit handler has set a batch, but make sure we
        // do not react to a batch that is already being processed (for instance
        // if a batch operation performs a
        // \Drupal\Core\Form\FormBuilderInterface::submitForm()).
        if (($batch =& $this->batchGet()) && !isset($batch['id'])) {
            // Some previous submit handler has set a batch. To ensure correct
            // execution order, store the call in a special 'control' batch set.
            // See _batch_next_set().
            $batch['sets'][] = [
                'form_submit' => $callback,
            ];
            $batch['has_form_submits'] = TRUE;
        }
        else {
            call_user_func_array($form_state->prepareCallback($callback), [
                &$form,
                &$form_state,
            ]);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.