项目作者: Abdelhadi92

项目描述 :
Yii2 toast alert widget
高级语言: JavaScript
项目地址: git://github.com/Abdelhadi92/yii2-toast.git
创建时间: 2018-11-04T22:27:04Z
项目社区:https://github.com/Abdelhadi92/yii2-toast

开源协议:MIT License

下载


Installation

Run the Composer command to install the latest version:

  1. composer require abushamleh/yii2-toast "dev-master"

Usage

ToastAlert

  1. use abushamleh\toast\ToastAlert;
  2. echo ToastAlert::widget([
  3. 'options' => [],
  4. 'heading' => 'heading',
  5. 'text' => 'text',
  6. 'type' => 'type',
  7. ]);

ToastBlock

ToastBlock widget renders a message from session flash. All flash messages are displayed in the sequence they were assigned using setFlash.

  1. use abushamleh\toast\ToastBlock;
  2. //You can set message as following:
  3. Yii::$app->session->setFlash('error', 'This is the message');
  4. Yii::$app->session->setFlash('success', 'This is the message');
  5. Yii::$app->session->setFlash('info', 'This is the message');
  6. Yii::$app->session->setFlash('info', ['heading' => 'Message title' 'text' => 'This is the message']);
  7. //Multiple messages could be set as follows:
  8. Yii::$app->session->setFlash('error', ['Error 1', 'Error 2']);
  9. Yii::$app->session->setFlash('error', [['heading' => 'Message title' 'text' => 'This is the message'], 'Error 2']);
  10. echo ToastBlock::widget([
  11. 'options' => []
  12. ]);