Core: Flash message

Created on 22 Feb 2017  路  2Comments  路  Source: adonisjs/core

Anybody knows how can I send a custom flash message after a success action? Thanks!

Ex:

* show(request, response) {
     let user = checkCrendetials('user', '12345')

     if(!user) {
      response.redirect('back')
      return
     }

      //Flash message here
      response.redirect('panel')
  }

Most helpful comment

Try something like that :

Controller :
yield request.with({flash: {type: 'success', message: 'My wounderful success message'}}).flash()
response.redirect('panel')

View :
{% for item in old('flash') %}
<li class="message-{{ item.type }}"> {{ item.message }} </li>
{% endfor %}

And read the doc : http://adonisjs.com/docs/3.2/sessions#_basic_usage_of_flash_messages ;)

All 2 comments

Try something like that :

Controller :
yield request.with({flash: {type: 'success', message: 'My wounderful success message'}}).flash()
response.redirect('panel')

View :
{% for item in old('flash') %}
<li class="message-{{ item.type }}"> {{ item.message }} </li>
{% endfor %}

And read the doc : http://adonisjs.com/docs/3.2/sessions#_basic_usage_of_flash_messages ;)

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

begueradj picture begueradj  路  3Comments

GianCastle picture GianCastle  路  3Comments

krunaldodiya picture krunaldodiya  路  3Comments

umaams picture umaams  路  3Comments

seanc picture seanc  路  4Comments