Display success message after submitting form I am try to display an success message after submitting my form and redirect to next page. The code I am using is the following. 

public function submitForm(array &amp;$form, FormStateInterface $form_state) {
  drupal_set_message(t('Form Submitted Successfully'), 'status', TRUE);
}


It doesn't work for me. 

Is there any alternate way to do it? What code should I use to display a success message?
The code you are showing is the same code Drupal core uses, for example in BanDelete::submitForm().

public function submitForm(array &amp;$form, FormStateInterface $form_state) {
  $this-&gt;ipManager-&gt;unbanIp($this-&gt;banIp);
  $this-&gt;logger('user')-&gt;notice('Deleted %ip', [
    '%ip' =&gt; $this-&gt;banIp,
  ]);
  drupal_set_message($this-&gt;t('The IP address %ip was deleted.', [
    '%ip' =&gt; $this-&gt;banIp,
  ]));
  $form_state-&gt;setRedirectUrl($this-&gt;getCancelUrl());
}


As drupal_set_message() is used from Drupal core in submitForm(), that is expected to work. I cannot say why it doesn't work in your case, since you don't show the full method code. It could also be there is a module that is interfering.

As for more OOP code, starting from Drupal 8.6, drupal_set_message() has been replaced with a service. the same code I showed (which is Drupal 8.4 code) has been changed to the following.

public function submitForm(array &amp;$form, FormStateInterface $form_state) {
  $this-&gt;ipManager-&gt;unbanIp($this-&gt;banIp);
  $this-&gt;logger('user')-&gt;notice('Deleted %ip', [
    '%ip' =&gt; $this-&gt;banIp,
  ]);
  $this-&gt;messenger()-&gt;addStatus($this-&gt;t('The IP address %ip was deleted.', [
    '%ip' =&gt; $this-&gt;banIp,
  ]));
  $form_state-&gt;setRedirectUrl($this-&gt;getCancelUrl());
}