hook_ajax_render_alter

hook_ajax_render_alter(array &$data)

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

Parameters

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

Related topics

Hooks
Define functions that alter the behavior of Drupal core.

File

core/lib/Drupal/Core/Form/form.api.php, line 153
Callbacks and hooks related to form system.

Code

function hook_ajax_render_alter(array &$data) {
  // Inject any new status messages into the content area.
  $status_messages = array('#type' => 'status_messages');
  $command = new \Drupal\Core\Ajax\PrependCommand('#block-system-main .content', \Drupal::service('renderer')->renderRoot($status_messages));
  $data[] = $command->render();
}
doc_Drupal
2016-10-29 09:17:49
Comments
Leave a Comment

Please login to continue.