Class app\widgets\Alert

Inheritanceapp\widgets\Alert » yii\bootstrap\Widget

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->getSession()->setFlash('error''This is the message');
\
Yii::$app->getSession()->setFlash('success''This is the message');
\
Yii::$app->getSession()->setFlash('info''This is the message');

Multiple messages could be set as follows:

\Yii::$app->getSession()->setFlash('error', ['Error 1''Error 2']);

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$alertTypes array The alert types configuration for the flash messages. app\widgets\Alert
$closeButton array The options for rendering the close button tag. app\widgets\Alert

Public Methods

Hide inherited methods

MethodDescriptionDefined By
init() app\widgets\Alert

Property Details

$alertTypes public property

The alert types configuration for the flash messages. This array is setup as $key => $value, where:

  • $key is the name of the session flash variable
  • $value is the bootstrap alert type (i.e. danger, success, info, warning)
public array $alertTypes = ['error' => 'alert-danger''danger' => 'alert-danger''success' => 'alert-success''info' => 'alert-info''warning' => 'alert-warning']
$closeButton public property

The options for rendering the close button tag.

public array $closeButton = []

Method Details

init() public method

public void init ( )