アクションでは、ユーザーにフィードバックを設定します。
$this->getUser()->setFlash('message', array(
"type" => "notice",
"content" => "Well done buddy, you did it."
));
$this->redirect('home/index');
ビューでは、次のコードを使用します。
<?php if ($sf_user->hasFlash('message')): $message = $sf_user->getFlash('message') ?>
<p class="<?php echo $message["type"] ?>" ><?php echo $message["content"]?></p>
<?php endif; ?>
ただし、メッセージは表示されません。
問題が「一度現れると消える」ということではなく、それが機能することを意味します。問題は、それが表示されないことです。一度もありません。
私はSymfony1.2を使用しています。これが、flashvarがユーザーオブジェクトにバインドされる理由です。