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;
}
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.