Yii Framework Forum: Flash message not shown - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Flash message not shown HTTP request was made 2 times ! Rate Topic: -----

#1 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 244
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 28 May 2012 - 04:40 AM

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 :(
And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

#2 User is offline   Joblo 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 380
  • Joined: 12-September 10
  • Location:Austria

Posted 28 May 2012 - 05:49 AM

Maybe this extension helps.
0

#3 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 244
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 28 May 2012 - 06:19 AM

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())
And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

#4 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 244
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 28 May 2012 - 06:53 AM

I just noticed that it works well on opera.
I wonder what is the difference between my form and the one @ contact page...
And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

#5 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 362
  • Joined: 15-March 11
  • Location:India

Posted 28 May 2012 - 06:57 AM

lets try to add
'autoUpdateFlash' => false,
in component array of config.
CodeSutra
0

#6 User is offline   Seal 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 126
  • Joined: 02-February 10

Posted 28 May 2012 - 11:56 AM

Have you tried
Yii::app()->user->setFlash('flashMessageId', 'Your Message');
from your controller?
Sylvester La-Tunje

Posted Image
0

#7 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 244
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 28 May 2012 - 01:59 PM

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;?>

And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

#8 User is offline   jiaming 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 261
  • Joined: 10-April 12

Posted 30 May 2012 - 05:37 AM

View Postsaegeek, on 28 May 2012 - 01:59 PM, said:

Problem is semi-solved



'autoUpdateFlash' => false,


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

#9 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 244
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 30 May 2012 - 07:04 AM

I already tried that and it doesn't solves anything.
The problem appears only on Firefox from version 12
And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

#10 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 244
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 30 May 2012 - 10:18 AM

Many other Firefox12 users experienced this problem:
http://support.mozil...uestions/926043
And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users