I have a problem with setting flash messages. So, i have an action which in some cases should redirect with flash. It looks like 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 i 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 is i don't see any message here. In Debug panel i see SESSION var populated with good flash, but it doesn't display with this if-statement. Maybe i need to configure session component or something?...
$this->redirect(\Yii::$app->request->getReferrer());
and displaying the flash message there. – Door