Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flash message not set #261

Closed
olsp opened this issue Mar 18, 2024 · 2 comments
Closed

Flash message not set #261

olsp opened this issue Mar 18, 2024 · 2 comments
Labels

Comments

@olsp
Copy link

olsp commented Mar 18, 2024

It seems like the flash messages aren't set.

When using the code from the docs, no flash message is shown:

{% if craft.app.session.hasFlash('notice') %}
   <p class="message notice">{{ craft.app.session.getFlash('notice') }}</p>
{% elseif craft.app.session.hasFlash('error') %}
   <p class="message error">{{ craft.app.session.getFlash('error') }}</p>
{% endif %}

{{ dump( craft.app.session ) }} outputs the following:

craft\web\Session {#201 ▼
  -_events: []
  -_eventWildcards: []
  -_behaviors: array:1 [▼
    "session" => craft\behaviors\SessionBehavior {#199 ▼
      +owner: craft\web\Session {#201}
      -_attachedEvents: []
      +authAccessParam: "84db923b1a58840fd78796ffb34fa2e1__auth_access"
      +assetBundleFlashKey: "__ab"
      +jsFlashKey: "__js"
    }
  ]
  +flashParam: "84db923b1a58840fd78796ffb34fa2e1__flash"
  +handler: null
  #_forceRegenerateId: null
  -_cookieParams: array:4 [▼
    "domain" => ""
    "secure" => true
    "httpOnly" => true
    "sameSite" => null
  ]
  -frozenSessionData: null
  -_hasSessionId: true
}

Additional info

  • Craft version: 5.0.0-beta.9
  • Plugin version: 3.1.0
@brandonkelly
Copy link
Member

Craft 5 uses the success key for successful flash messages, rather than notice. Just updated the readme to clarify that.

@iamkeir
Copy link

iamkeir commented Jun 12, 2024

@brandonkelly a bit confused here - in the context of Craft 5, the contact form plugin sets a successful flash as success but Craft 5 itself still uses notice?

Ref: https://docs.craftcms.com/api/v5/craft-web-session.html#method-getflash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants