Skip to main content
Tweeted twitter.com/StackDrupal/status/939546443198627842
improved grammar
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

How to do theI redirect users and show a message in Drupal 8?

I want to do redirectionredirect users with RedirectResponse:RedirectResponse and display a message, but the message is not displayed.

$response = new RedirectResponse($url);
$response->send();

and display the message after the redirection. But message isn't displayed. AfterAfter little debugging I found that my initial (source) urlURL is loaded twice, and drupalthe messages (viaadded with drupal_set_message()) are removingremoved from $_SESSIONthe session in function drupal_get_messages(). So I have no messages on my target $url.

Could somebody give me an adviceHow can I achieve this?

Thanks in advance.

P.S. I'm doing it in hook_field_widget_form_alter().

How to do the redirect and show message in Drupal 8

I want to do redirection with RedirectResponse:

$response = new RedirectResponse($url);
$response->send();

and display the message after the redirection. But message isn't displayed. After little debugging I found that my initial (source) url loaded twice and drupal messages (via drupal_set_message) are removing from $_SESSION in function drupal_get_messages. So I have no messages on my target $url.

Could somebody give me an advice?

Thanks in advance.

P.S. I'm doing it in hook_field_widget_form_alter.

How do I redirect users and show a message?

I want to redirect users with RedirectResponse and display a message, but the message is not displayed.

$response = new RedirectResponse($url);
$response->send();

After little debugging I found that my initial (source) URL is loaded twice, and the messages (added with drupal_set_message()) are removed from the session in drupal_get_messages(). So I have no messages on my target $url.

How can I achieve this?

I'm doing it in hook_field_widget_form_alter().

added 5 characters in body
Source Link
Eugene
  • 2.4k
  • 1
  • 19
  • 27

I want to do redirection with RedirectResponse:

$response = new RedirectResponse($url);
$response->send();

and display the message after the redirection. But message isn't displayed. After little debugging I found that my initial (source) url loaded twice and drupal messages (via drupal_set_message) are removing from $_SESSION in function drupal_get_messages. So I have notno messages on my target $url.

Could somebody give me an advice?

Thanks in advance.

P.S. I'm doing it in hook_field_widget_form_alter.

I want to do redirection with RedirectResponse:

$response = new RedirectResponse($url);
$response->send();

and display the message after the redirection. But message isn't displayed. After little debugging I found that my initial (source) url loaded twice and drupal messages drupal_set_message are removing from $_SESSION in function drupal_get_messages. So I have not messages on my target $url.

Could somebody give me an advice?

Thanks in advance.

P.S. I'm doing it in hook_field_widget_form_alter.

I want to do redirection with RedirectResponse:

$response = new RedirectResponse($url);
$response->send();

and display the message after the redirection. But message isn't displayed. After little debugging I found that my initial (source) url loaded twice and drupal messages (via drupal_set_message) are removing from $_SESSION in function drupal_get_messages. So I have no messages on my target $url.

Could somebody give me an advice?

Thanks in advance.

P.S. I'm doing it in hook_field_widget_form_alter.

improve formating
Source Link
Adeel Nawaz
  • 3.2k
  • 1
  • 16
  • 24

I want to do redirection with RedirectResponse:

$response = new RedirectResponse($url);
$response->send();

and display the message after the redirection. But message isn't displayed. After little debugging I found that my initial (source) url loaded twice and drupal messages (drupal_set_message)drupal_set_message are removing from $_SESSION$_SESSION in function drupal_get_messagesdrupal_get_messages. So I have not messages on my target $url$url.

Could somebody give me an advice?

Thanks in advance.

P.S. I'm doing it in hook_field_widget_form_alterhook_field_widget_form_alter.

I want to do redirection with RedirectResponse:

$response = new RedirectResponse($url);
$response->send();

and display the message after the redirection. But message isn't displayed. After little debugging I found that my initial (source) url loaded twice and drupal messages (drupal_set_message) are removing from $_SESSION in function drupal_get_messages. So I have not messages on my target $url.

Could somebody give me an advice?

Thanks in advance.

P.S. I'm doing it in hook_field_widget_form_alter.

I want to do redirection with RedirectResponse:

$response = new RedirectResponse($url);
$response->send();

and display the message after the redirection. But message isn't displayed. After little debugging I found that my initial (source) url loaded twice and drupal messages drupal_set_message are removing from $_SESSION in function drupal_get_messages. So I have not messages on my target $url.

Could somebody give me an advice?

Thanks in advance.

P.S. I'm doing it in hook_field_widget_form_alter.

Source Link
Eugene
  • 2.4k
  • 1
  • 19
  • 27
Loading