FlashPopupWidget is a Yii2 widget that displays session flashes as popups based on the flash types.
Install the widget using Composer:
composer require xililo/flash-popup-widget
Let's say you have the folowing in the controller:
Yii::$app->session->addFlash('danger', 'Log in to proceed with the operation.');
Import the FlashPopupWidget class at the top of your main layout view or any view file (e.g. in your views/layouts/main.php
):
use xililo\Popups\FlashPopupWidget;
Place the widget call in your view file or controller where you want to display the flashes and trigger the popups:
echo FlashPopupWidget::widget();
This will render the FlashPopupWidget popups based on the flash types.