- Alert widget based on bootstrap-sweetalert extension http://lipis.github.io/bootstrap-sweetalert
Installation
The preferred way to install this extension is through composer., (*1)
Either run, (*2)
php composer.phar require --prefer-dist drexlerux/yii2-bootstrap-sweetalert "*"
or add, (*3)
"drexlerux/yii2-bootstrap-sweetalert": "*"
to the require section of your composer.json., (*4)
Usage
Once the extension is installed, simply add widget to your page as follows:, (*5)
echo \drexlerux\sweetalert\SweetAlert::widget([
'type' => \drexlerux\sweetalert\SweetAlert::TYPE_WARNING,
'options' => [
'title' => 'Warning message',
'text' => "Do you want to delete it?",
'confirmButtonText' => "Yes, delete it!",
'cancelButtonText' => "No, cancel plx!"
]
]);
Overrid Confirm
SweetAlertAsset overrides javascript confirm dialog by default.
If you want to keep default edit your config.php, (*6)
'assetManager' => [
'bundles' => [
'drexlerux\sweetalert\SweetAlertAsset' => [
'overrideConfirm' => false
]
]
]
Alert Options
You can find them on the options page, (*7)