Alert
extends Widget
in package
Alert widget renders a message from session flash. All flash messages are displayed in the sequence they were assigned using setFlash. 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');
Multiple messages could be set as follows:
Yii::$app->session->setFlash('error', ['Error 1', 'Error 2']);
Tags
Table of Contents
- $alertTypes : array<string|int, mixed>
- $closeButton : array<string|int, mixed>
- run() : mixed
- {@inheritdoc}
Properties
$alertTypes
public
array<string|int, mixed>
$alertTypes
= ['error' => 'alert-danger', 'danger' => 'alert-danger', 'success' => 'alert-success', 'info' => 'alert-info', 'warning' => 'alert-warning']
the alert types configuration for the flash messages. This array is setup as $key => $value, where:
- key: the name of the session flash variable
- value: the bootstrap alert type (i.e. danger, success, info, warning)
$closeButton
public
array<string|int, mixed>
$closeButton
= []
the options for rendering the close button tag. Array will be passed to [[\yii\bootstrap\Alert::closeButton]].
Methods
run()
{@inheritdoc}
public
run() : mixed