Is it possible to show flash messages in Symfony 2 without redirect? Or editing core files in another possible solution on google groups?
//Symfony\Component\HttpFoundation\Session
public function setFlash($name, $value, $persist = true)
{
if (false === $this->started) {
$this->start();
}
$this->flashes[$name] = $value;
if($persist) {
unset($this->oldFlashes[$name]);
}
else {
$this->oldFlashes[$name] = $value;
}
}
UPDATE
Oh actually I noticed if I just used a forward, flash messages will show, but it will still show on next request
Why using flashes if you don’t want them to be persisted until next request ?
Couldn’t you find other ways to display feedback like template parameters ?
If not, you could add this in your templates (according you are displaying flashes like below):
So that any template that displays these flashes before redirection will remove them from session before returning the response. I think it’s the last better solution.