Giter Site home page Giter Site logo

Comments (12)

choffmeister avatar choffmeister commented on May 6, 2024

I guess this happens, if u add a flash message and do not redirect. The general scenario is

  • post a form
  • progress the form, add a flash, redirect to another page
  • show the page redirected to

To make the flashmessage visible it lifes exactly two page calls (the redirecting page and the page after).

from symfony.

Burgov avatar Burgov commented on May 6, 2024

Strange... What happens if the request is redirected twice? Will the Flash message disappear?

from symfony.

choffmeister avatar choffmeister commented on May 6, 2024

Haven't tested it but I guess yes.

from symfony.

choffmeister avatar choffmeister commented on May 6, 2024

In symfony 1 there was an Boolean parameter at the setFlash method named persist. If it was false, then the flash message only lifed one call (for non redirected pages) and if it was true, then it lifed two calls (for redirected pages).

from symfony.

michelsalib avatar michelsalib commented on May 6, 2024

You are right. But I keep asking myself why flash should persist until one first call and then be flush. So that we never have to care about if the page is redirected or not.

from symfony.

vlechemin avatar vlechemin commented on May 6, 2024

On Tue, May 3, 2011 at 9:09 PM, choffmeister
[email protected]
wrote:

I guess this happens, if u add a flash message and do not redirect. The general scenario is

  • post a form
  • progress the form, add a flash, redirect to another page
  • show the page redirected to

To make the flashmessage visible it lifes exactly two page calls (the redirecting page and the page after).

You are right, it's indeed what happens. Thanks,

Vincent

from symfony.

vlechemin avatar vlechemin commented on May 6, 2024

I'm not sure it would work, but isn't it better to flag the flash
messages as old when we are in the render view event instead of when
the session starts?

Vincent

from symfony.

Seldaek avatar Seldaek commented on May 6, 2024

The thing is that flash messages are only useful when you redirect. If you don't redirect, then you can just pass the message to your template straight away, no need to go through the session store for that.

If you do redirect, then the system works well, unless you redirect twice in a row, but I really don't see why you would do that. This is bad practice for performance reasons, especially on mobile connections; and the valid use cases for doing this are extremely rare.

from symfony.

fabpot avatar fabpot commented on May 6, 2024

@Seldaek gave a good explanation here. I'm closing this ticket.

from symfony.

Glideh avatar Glideh commented on May 6, 2024

Wouldn't it be simpler to pop each fetched message ?
That is the behavior in Django. So the question is not asked.
And yes we can directly pass flashes to templates, we can also set our own session variables... :)

from symfony.

fabpot avatar fabpot commented on May 6, 2024

@Glideh That's the behavior as of Symfony 2.1.

from symfony.

Glideh avatar Glideh commented on May 6, 2024

Ho sorry I was using 2.0 :) thanks for the notice

from symfony.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.