https://github.com/abdelhadi92/yii2-toast
Yii2 toast alert widget
https://github.com/abdelhadi92/yii2-toast
php toast toast-notifications yii2 yii2-widgets
Last synced: about 1 month ago
JSON representation
Yii2 toast alert widget
- Host: GitHub
- URL: https://github.com/abdelhadi92/yii2-toast
- Owner: Abdelhadi92
- License: mit
- Created: 2018-11-04T22:27:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-04T22:41:25.000Z (over 6 years ago)
- Last Synced: 2025-04-23T21:51:33.078Z (about 1 month ago)
- Topics: php, toast, toast-notifications, yii2, yii2-widgets
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Installation
Run the [Composer](http://getcomposer.org/download/) command to install the latest version:
```
composer require abushamleh/yii2-toast "dev-master"
```## Usage
### ToastAlert
```php
use abushamleh\toast\ToastAlert;echo ToastAlert::widget([
'options' => [],
'heading' => 'heading',
'text' => 'text',
'type' => 'type',
]);```
### ToastBlock
ToastBlock widget renders a message from session flash. All flash messages are displayed in the sequence they were assigned using setFlash.
```php
use abushamleh\toast\ToastBlock;//You can set message as following:
Yii::$app->session->setFlash('error', 'This is the message');
Yii::$app->session->setFlash('success', 'This is the message');
Yii::$app->session->setFlash('info', 'This is the message');
Yii::$app->session->setFlash('info', ['heading' => 'Message title' 'text' => 'This is the message']);//Multiple messages could be set as follows:
Yii::$app->session->setFlash('error', ['Error 1', 'Error 2']);
Yii::$app->session->setFlash('error', [['heading' => 'Message title' 'text' => 'This is the message'], 'Error 2']);echo ToastBlock::widget([
'options' => []
]);```