πŸ‡ΊπŸ‡ΈUnited States @mattc321

Account created on 19 June 2014, over 10 years ago
#

Recent comments

πŸ‡ΊπŸ‡ΈUnited States mattc321

I extend my own MessageCommand to make this easier to reuse, but here is a direct simplified work around, returning a proper status message. Of course, many ways to do this while we await the fix in 3396318 πŸ› AJAX MessageCommand markup and styling differs from Theme default Needs work

public function myControllerResponseOrAjaxCallback() {
    $build = [
      '#theme' => 'status_messages',
      '#message_list' => [
        'error' => [
          '#markup' => t('An error occurred!'),
        ]
      ],
      '#status_headings' => [
        'status' => t('Status message'),
        'error' => t('Error message'),
        'warning' => t('Warning message'),
      ],
    ];

    $output = \Drupal::service('renderer')->render($build);
    $response = new AjaxResponse();
    $response->addCommand(new MessageCommand($output));
    return $response;
  }
Production build 0.71.5 2024