yii2-notification-wrapper Yii2-notification-wrapper module renders a message from session flash (with ajax support).

Yii2-notification-wrapper module renders a message from session flash (with ajax support). All flash messages are displayed in the sequence they were assigned using setFlash. You can set message as following:

public function actionIndex(){
    ...
     \Yii::$app->getSession()->setFlash('error',   'noty1');
     \Yii::$app->getSession()->setFlash('info',    'noty2');
     \Yii::$app->getSession()->setFlash('success', 'noty3');
     \Yii::$app->getSession()->setFlash('warning', 'noty4');
    ...
     return $this->render('index');
 }
 // or in ajax action

 public function actionAjax(){
     ...
      \Yii::$app->getSession()->setFlash('error',   'ajax-noty1');
      \Yii::$app->getSession()->setFlash('info',    'ajax-noty2');
      \Yii::$app->getSession()->setFlash('success', 'ajax-noty3');
      \Yii::$app->getSession()->setFlash('warning', 'ajax-noty4');
     ...
     $data = 'Some data to be returned in response to ajax request';
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     return $data;
  }

Resources ΒΆ

1 0
1 follower
0 downloads
Yii Version: 2.0
License: BSD-2-Clause
Category: User Interface
Developed by: loveorigami
Created on: Mar 21, 2016
Last updated: 8 years ago

Related Extensions