Comments (12)
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.
Strange... What happens if the request is redirected twice? Will the Flash message disappear?
from symfony.
Haven't tested it but I guess yes.
from symfony.
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.
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.
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.
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.
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.
@Seldaek gave a good explanation here. I'm closing this ticket.
from symfony.
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.
@Glideh That's the behavior as of Symfony 2.1.
from symfony.
Ho sorry I was using 2.0 :) thanks for the notice
from symfony.
Related Issues (20)
- [Messenger][Doctrine] Deadlock when deleting message
- [Messenger] Error "Cannot modify readonly property Doctrine\ORM\EntityManager::$conn" on messenger:consume HOT 5
- [Serializer] Attribute `SerializedName` ignored when property name is the same as the related (get|has|can) method HOT 4
- _fragment does not work with RedirectToRoute when turbo enabled HOT 5
- shell_exec returning null from stty command HOT 1
- TableNotFound exception not handled in MySQL handling in Connection::get with autoSetup enabled HOT 1
- [AssetMapper] Remove unused method / BC break ? HOT 1
- [Messenger] Provide a deduplication strategy to Queue HOT 3
- JavaScriptImportPathCompiler::compile(): Return value must be of type string, null returned HOT 3
- 3rd party js library not found after install with asset mapper HOT 6
- [RFC] AssetMapper: use "module" key file when available HOT 6
- [OptionsResolver] Fix allowed types not defined as string
- Allow specifying status code for validation error when mapping query parameters using #[MapQueryParameter] HOT 1
- [DependencyInjection] Named argument might be unresolved in ChildDefinition
- AssetMapper lodash (and potentially other libs) install problem HOT 2
- Symfony\Component\AssetMapper\Compiler\JavaScriptImportPathCompiler::compile(): Return value must be of type string, none returned").
- Problem when installing symfony webapp HOT 1
- [YamlComponent] Dump enums with `!php/enum` instead of `!php/const` HOT 1
- bin/console config:dump-reference dumps invalid yaml HOT 4
- [Serializer] Add XmlEncoder::CDATA_WRAPPING_PATTERN context option
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from symfony.