function hook_ajax_render_alter

Same name and namespace in other branches
  1. 7.x modules/system/system.api.php \hook_ajax_render_alter()
  2. 9 core/lib/Drupal/Core/Form/form.api.php \hook_ajax_render_alter()
  3. 10 core/lib/Drupal/Core/Form/form.api.php \hook_ajax_render_alter()
  4. 11.x core/lib/Drupal/Core/Form/form.api.php \hook_ajax_render_alter()

Alter the Ajax command data that is sent to the client.


\Drupal\Core\Ajax\CommandInterface[] $data: An array of all the rendered commands that will be sent to the client.

Related topics

1 invocation of hook_ajax_render_alter()
AjaxResponseAttachmentsProcessor::buildAttachmentsCommands in core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php
Prepares the AJAX commands to attach assets.


core/lib/Drupal/Core/Form/form.api.php, line 153


function hook_ajax_render_alter(array &$data) {
    // Inject any new status messages into the content area.
    $status_messages = [
        '#type' => 'status_messages',
    $command = new \Drupal\Core\Ajax\PrependCommand('#block-system-main .content', \Drupal::service('renderer')->renderRoot($status_messages));
    $data[] = $command->render();

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