In an action, I set some feedback for the user :
$this->getUser()->setFlash('message', array(
"type" => "notice",
"content" => "Well done buddy, you did it."
));
$this->redirect('home/index');
In the view, I just use the following code :
<?php if ($sf_user->hasFlash('message')): $message = $sf_user->getFlash('message') ?>
<p class="<?php echo $message["type"] ?>" ><?php echo $message["content"]?></p>
<?php endif; ?>
But the message never appears.
Not that the problem is not 'it appears once then it disapears' cause that would mean it works. The problem is that it never appears. Not once.
I'm using Symfony 1.2, this is why flash var are now binded to the user object.
Try the same with two setFlash
with strings (not array). I think this will work. Symfony is escaping arrays when accessing it in the template. try var_dump($sf_user->getFlash('message'));
to be sure what you get.