Flash message not shown

Hi,

I’m trying to show a flash message as a result of a just sent form.

The code i used is the same as the one at contact-page except my form header:




<?php $form=$this->beginWidget('CActiveForm', array(

        'id'=>'feedbacks-form',

	'enableAjaxValidation'=>false,

        'action'=>'products/details',

)); ?>



I think my browser (Firefox 12) loads the “resulting page” from cache because when i set a new session var that i increment at each page visit, the counter doesn’t refresh :




<?php if (Yii::app()->user->getState('foo')===NULL) {

    Yii::app()->user->setState('foo',1);

} else {

    $x=Yii::app()->user->getState('foo');

    Yii::app()->user->setState('foo',++$x);

}

print_r(Yii::app()->user->getState('foo'));?>



The only way to show the flash message is:




<?php if (Yii::app()->user->hasFlash('feedback')):?>

    <div class="flash-success">

        <?php echo Yii::app()->user->getFlash('feedback');?>

    </div>

<?php exit;endif;?>



But “exit” is not a solution :(

Maybe this extension helps.

I would like to reproduce the same scenario as contact page.

Don’t need of more effects.

On the contact page the session counter i made increments perfectly (+1) :




<?php if (Yii::app()->user->getState('foo')===NULL) {

    Yii::app()->user->setState('foo',1);

} else {

    $x=Yii::app()->user->getState('foo');

    Yii::app()->user->setState('foo',++$x);

}

print_r(Yii::app()->user->getState('foo'));?>



but at my web page i just get the non-incremented value, maybe browser-cache ?

when i disable browser cache using cache toggle

it increments by +2 at the returned page (page with getflash())

I just noticed that it works well on opera.

I wonder what is the difference between my form and the one @ contact page…

lets try to add


'autoUpdateFlash' => false,

in component array of config.

Have you tried


Yii::app()->user->setFlash('flashMessageId', 'Your Message');

from your controller?

Problem is semi-solved

I downgraded firefox from v12 to v11 and it worked one shot !

In v12 the returned page is loaded from cache and when i disable browser cache, Firefox asks for the page one-more time and because of this behavior the flash message is removed. When i exit() after getFlash() i can see the flash message.

my controller :




public function actionDetails($id) {

        $this->loadModel($id);

        $feedbacks=new Feedbacks;

        if (isset($_POST['Feedbacks'])) {

            $feedbacks->attributes=$_POST['Feedbacks'];

        ...

        ...

        if ($feedbacks->save()) {

                ...

                ...

                Yii::app()->mailer->Send();

                Yii::app()->user->setFlash('feedback','Your feedback was received, it will be shown once it is approved.');

                $this->refresh();

            }

$this->render('details',array(

    ...



my view:




<?php

$this->widget('CTabView',array(

    'cssFile'=>'/css/tabs.css',

    'activeTab'=>(Yii::app()->request->isPostRequest?'tab2':'tab1'),

    'tabs'=>array(

        'tab1'=>array(

            'title'=>'View feedbacks',

            'view'=>'feedbacks/_list',

            'data'=>array(

                'dataProvider'=>$dataProvider,

                'product_id'=>$product_id,

            ),

        ),

        'tab2'=>array(

            'title'=>'Post a feedback',

            'view'=>'feedbacks/_form',

            'data'=>array(

                'feedbacks'=>$feedbacks,

            ),

        ),

)));



_list tab:




<?php if (Yii::app()->user->hasFlash('feedback')):?>

    <div class="flash-success">

        <?php echo Yii::app()->user->getFlash('feedback');?>

    </div>

<?php endif;?>




'autoUpdateFlash' => false,

Add this line, your problem will be solved in just 1 second.

I already tried that and it doesn’t solves anything.

The problem appears only on Firefox from version 12

Many other Firefox12 users experienced this problem:

http://support.mozilla.org/fr/questions/926043