You are here

public static function AjaxTestFormPromise::executeCommands in Drupal 10

Ajax callback for the "Execute commands button" button.

File

core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestFormPromise.php, line 53

Class

AjaxTestFormPromise
Test form for ajax_test_form_promise.

Namespace

Drupal\ajax_test\Form

Code

public static function executeCommands(array $form, FormStateInterface $form_state) {
  $selector = '#ajax_test_form_promise_wrapper';
  $response = new AjaxResponse();
  $response
    ->addCommand(new AppendCommand($selector, '1'));
  $response
    ->addCommand(new AjaxTestCommandReturnPromise($selector, '2'));
  $response
    ->addCommand(new AppendCommand($selector, '3'));
  $response
    ->addCommand(new AppendCommand($selector, '4'));
  $response
    ->addCommand(new AjaxTestCommandReturnPromise($selector, '5'));
  return $response;
}