Display status message after submitting modal popup form Ok so i have a custom entity and want to display a custom delete form. Have created the Route and everything works except for Drupal messenger displaying status message after submission, even after a manual refresh.
The weird thing is, if i add a ksm() output to hook_entity_delete() which is called after the entity is deleted, the status message does display.
I have added a '?destination=' parameter to the end of the link the initiates the popup, and after submit, the redirect is successful.
Here is my class, which i can get to popup in a dialog window, with the form and successful deletion and window close.
Just to clarify, trying to get the status message to display on the form from where the modal popup was initiated from, not to get the message in an additional popup.
Any ideas?
class TrEntryDeleteForm extends ConfirmFormBase {

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $na_entry = NULL) {

    $entry_id = $na_entry-&gt;id();

    $form['title'] = [
      '#markup' =&gt; t(&quot;&lt;p&gt;Title&lt;/p&gt;&quot;),
    ];

    $form['description'] = [
      '#markup' =&gt; t(&quot;&lt;p class='text-center'&gt;This action can't be undone&lt;/p&gt;&quot;),
    ];

    $form['entry_id'] = [
      '#type' =&gt; 'hidden',
      '#default_value' =&gt; $entry_id,
      '#required' =&gt; TRUE,
    ];

    $form['actions'] = [
      '#type' =&gt; 'actions',
    ];

    $form['actions']['cancel'] = [
      '#type' =&gt; 'submit',
      '#value' =&gt; $this-&gt;t('Cancel'),
      '#attributes' =&gt; [
        'class' =&gt; [
          'use-ajax',
          'cancel',
        ],
      ],
      '#ajax' =&gt; [
        'callback' =&gt; [$this, 'closeModalForm'],
        'event' =&gt; 'click',
      ],
    ];

    $form['actions']['submit'] = [
      '#type' =&gt; 'submit',
      '#value' =&gt; $this-&gt;t('Delete'),
    ];

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &amp;$form, FormStateInterface $form_state) {

    $entry_entity = \Drupal::entityTypeManager()-&gt;getStorage('entry')-&gt;load($entry_id);
    $entry_entity-&gt;delete();

    \Drupal::messenger()-&gt;addStatus(
      t('@msg', ['@msg' =&gt; 'Entity deleted.'])
    );
  }

  /**
   * {@inheritdoc}
   */
  public function getQuestion() {

  }

  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    // TODO: Implement getCancelUrl() method.
  }

}
After redirection the \Drupal::messenger() may not work. So try with the Drupal OpenModalDialogCommand
use Drupal\Core\Ajax\OpenModalDialogCommand;

/**
* {@inheritdoc}
*/
  public function submitForm(array &amp;$form, FormStateInterface $form_state){
    
    $entry_entity = \Drupal::entityTypeManager()-&gt;getStorage('entry')-&gt;load($entry_id);
    $entry_entity-&gt;delete();

    $response = new AjaxResponse();
    $response-&gt;addCommand(new OpenModalDialogCommand(&quot;Success&quot;, 'Entity deleted.', ['width' =&gt; 800]));
    return $response;
  }