function FormSubmitter::executeSubmitHandlers
Executes custom submission handlers for a given form.
Button-specific handlers are checked first. If none exist, the function falls back to form-level handlers.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. If the user submitted the form by clicking a button with custom handler functions defined, those handlers will be stored here.
Overrides FormSubmitterInterface::executeSubmitHandlers
1 call to FormSubmitter::executeSubmitHandlers()
- FormSubmitter::doSubmitForm in core/lib/ Drupal/ Core/ Form/ FormSubmitter.php 
- Handles the submitted form, executing callbacks and processing responses.
File
- 
              core/lib/ Drupal/ Core/ Form/ FormSubmitter.php, line 108 
Class
- FormSubmitter
- Provides submission processing for forms.
Namespace
Drupal\Core\FormCode
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.
