- Alert widget based on SweetAlert extension http://tristanedwards.me/sweetalert
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist yii2mod/yii2-sweet-alert "*"
or add
"yii2mod/yii2-sweet-alert": "*"
to the require section of your composer.json.
Once the extension is installed, simply add widget to your page as follows:
- Default usage, render all flash messages stored in session flash via Yii::$app->session->setFlash().
echo Alert::widget();
- Custom usage example:
echo \yii2mod\alert\Alert::widget([
'type' => \yii2mod\alert\Alert::TYPE_WARNING,
'options' => [
'title' => 'Success message',
'text' => "You will not be able to recover this imaginary file!",
'confirmButtonText' => "Yes, delete it!",
'cancelButtonText' => "No, cancel plx!"
]
]);
You can find them on the options page