Does Craft have any default keys for flash messages like logging in or updating a profile?

  • Do you mean for the backend, to display messages in Crafts native alert message format? – naboovalley Nov 17 '14 at 21:30
  • For the frontend, so you can do something like {% set message = craft.session.getFlash('login') %} for example. – Hasco Nov 17 '14 at 21:31

Not particularly.

UserSessionService has setNotice() and setErrors(), which are just wrappers for Yii's setFlash() where we pass in an 'error' or 'notice' for the key.

Yii will take than and prepend the FLASH_KEY_PREFIX const which we set to Craft.UserSessionService.flash..

So an error's key will end up being Craft.UserSessionService.flash.error and a notice will be Craft.UserSessionService.flash.notice.

  • So with this I would be able to do something like this craft.session.getFlash('notice', 'Your settings have been saved')? Only with the limitation that only one notice can be stored at a time. – Hasco Nov 17 '14 at 21:37
  • Sounds pretty solid to me. – Brad Bell Nov 17 '14 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.