Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
LICENSE.md
README.md
composer.json

README.md

ruturajmaniyar/yii2-flash-toastr

Toastr flash notification using jQuery with yii2

GitHub release Packagist

Current Version

v1.0 @stable @pre-release

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist ruturajmaniyar/yii2-flash-toastr: "dev-master"

or

composer require --prefer-dist ruturajmaniyar/yii2-flash-toastr: "dev-master"

or add

"ruturajmaniyar/yii2-flash-toastr": "dev-master"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

<?php if (Yii::$app->session->hasFlash('success')): ?>
    <?= ToastrFlashMessage::widget([
        'type' => 'success',
        'title' => 'Success',
        'message' => Yii::$app->session->getFlash('success')
    ]); ?>
<?php endif; ?>

<?php if (Yii::$app->session->hasFlash('error')): ?>
    <?= ToastrFlashMessage::widget([
        'type' => 'error',
        'title' => 'Error',
        'message' => Yii::$app->session->getFlash('error')
    ]); ?>
<?php endif; ?>

You can also use with below code

<?= ToastrFlashMessageSession::widget() ?>

With above code, extension set toastr message dynamically based on your flash session message

Other Options

'options' => [
        "closeButton" => true,
        "newestOnTop" => true,
        "progressBar" => true,
        "positionClass" => ToastrFlashMessage::POSITION_TOP_RIGHT,
        "showDuration" => "300", 
        "hideDuration" => "1000",
        "timeOut" => "5000",
        "extendedTimeOut" => "1000",
        "showEasing" => "swing",
        "hideEasing" => "linear",
        "closeEasing" => "linear",
        "showMethod" => "slideDown",
        "hideMethod" => "slideUp",
        "closeMethod" => "slideUp"
    ]
Toast Position Options:
POSITION_TOP_RIGHT = 'toast-top-right';
POSITION_TOP_LEFT = 'toast-top-left';
POSITION_TOP_CENTER = 'toast-top-center';
POSITION_TOP_FULL_WIDTH = 'toast-top-full-width';

POSITION_BOTTOM_RIGHT = 'toast-bottom-right';
POSITION_BOTTOM_LEFT = 'toast-bottom-left';
POSITION_BOTTOM_CENTER = 'toast-bottom-center';
POSITION_BOTTOM_FULL_WIDTH = 'toast-bottom-full-width';
DEMO
You can’t perform that action at this time.