yii2-toastr
This is the Toastr extension for Yii 2. It encapsulates Toastr plugin in terms of Yii widgets., (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist alikdex/yii2-toastr "*"
or add, (*4)
"alikdex/yii2-toastr": "*"
to the require section of your composer.json
file., (*5)
Usage
Once the extension is installed, you can test that the extension works by simply use it in your code by :, (*6)
<?= \alikdex\toastr\Toastr::widget([
'toastType' => 'error',
'message' => 'This is an error.',
]);?>
There are 2 main useful widgets, (*7)
ToastrAlert
displays Yii flash messages in toastr notification style, (*8)
<?php
$session = \Yii::$app->getSession();
$session->setFlash('error', "msg1");
$session->setFlash('danger', "msg2");
$session->setFlash('warning', "msg3");
$session->setFlash('info', "msg4");
$session->setFlash('success', "msg5");
?>
<?= \alikdex\toastr\ToastrAlert::widget([
'options' => [
'positionClass' => 'toast-bottom-left'
]
]);?>