Alert Extension for Yii2
Via composer
add to your 'require' section in file 'composer.json', (*1)
"require": {
...
"maximkozhin/yii2-alert-session": "*"
},
or run command, (*2)
$ composer require maximkozhin/yii2-alert-session
1. Configuration | Конфигурация
insert into you config file, (*3)
'components' => [
...
'session' => [
'class' => 'maximkozhin\alert\components\session',
'flashIndex' => 'flash'
],
...
2. Usage | Использование
To create a Flash Message, (*4)
Yii::$app->session->addFlash($type, $message);
or
Yii::$app->session->setFlash($type, $message);
Your flash messages don't group by type, outputing by the FIFO principe, (*5)
2. Layout | Вывод
add to your layout file, (*6)
...
<!-- CSS styles in css-file /your/vendor/path/maximkozhin/alert/dist/css/alert.css -->
<div class="flash-messages">
<?=\maximkozhin\alert\widgets\Alert::widget()?>
</div>
...