Yii2 Session, Flash messages -


i have problem setting flash messages. so, have action in cases should redirect flash. looks this:

if(!$this->_issameorg($reports)){     \yii::$app->session->setflash('consol_v_error',\yii::t('app/consol', 'some_text'));     $this->redirect(\yii::$app->request->getreferrer());     return; } 

after redirect in view have this

<div class="col-lg-12">     <?php if(yii::$app->session->hasflash('consol_v_error')): ?>         <div class="alert alert-danger" role="alert">             <?= yii::$app->session->getflash('consol_v_error') ?>         </div>     <?php endif; ?> </div> 

the problem don't see message here. in debug panel see session var populated flash, doesn't display if-statement. maybe need configure session component or something?...

to set flash,try like

  \yii::$app->getsession()->setflash('error', 'your text here..');    return $this->redirect('your action'); 

and display it..

   <?= yii::$app->session->getflash('error'); ?> 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -