Skip to content

Instantly share code, notes, and snippets.

@imghasemi
Last active August 7, 2019 13:58
Show Gist options
  • Save imghasemi/fef6241cf9309dc595891cdd65b3d258 to your computer and use it in GitHub Desktop.
Save imghasemi/fef6241cf9309dc595891cdd65b3d258 to your computer and use it in GitHub Desktop.
Drupal status message with AJAX for Drupal 8
<?php
$response = new AjaxResponse();
$status_messages = array('#type' => 'status_messages');
$messages = \Drupal::service('renderer')->renderRoot($status_messages);
if (!empty($messages)) {
$response->addCommand(new PrependCommand('.your_selector', $messages));
}
return $response;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment