alikdex/yii2-toastr

Yii2 widget for jquery toastr notifications

Installs: 201

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0 2016-08-24 15:02 UTC

This package is auto-updated.

Last update: 2024-10-17 09:49:33 UTC


README

Toastr notifications widget for yii2

This is the Toastr extension for Yii 2. It encapsulates Toastr plugin in terms of Yii widgets.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist alikdex/yii2-toastr "*"

or add

"alikdex/yii2-toastr": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, you can test that the extension works by simply use it in your code by :

<?= \alikdex\toastr\Toastr::widget([
    'toastType' => 'error',
    'message' => 'This is an error.',
]);?>

There are 2 main useful widgets

ToastrAlert

displays Yii flash messages in toastr notification style

<?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'
    ]
]);?>