/** * Implements hook_ajax_render_alter(). */ function {{ machine_name }}_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(); }