kamran377/yii2-sweetalert2

Alert widget based on SweetAlert2 extension {@link https://sweetalert2.github.io/)

Installs: 218

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 1

Open Issues: 0

Type:yii2-extension

2.1.0 2024-03-07 16:59 UTC

This package is auto-updated.

Last update: 2024-05-07 17:32:54 UTC


README

993323

Yii2 Sweet Alert2 Widget


Alert widget based on SweetAlert2

Latest Stable Version Total Downloads License Build Status

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist kamran377/yii2-sweetalert2 "*"

or add

"kamran377/yii2-sweetalert2": "*"

to the require section of your composer.json.

Usage

For render the message from session flash you can use the following code:

  1. Set the message in your action, for example:
Yii::$app->session->setFlash('success', 'This is the message');
  1. Simply add widget to your page as follows:
echo kamran377\sweetalert2\SweetAlert::widget();

For render the custom message you can use the following code:

// A replacement for the "prompt" function

echo \kamran377\yii2-sweetalert2\SweetAlert::widget([
        'type' => \kamran377\yii2-sweetalert2\SweetAlert::TYPE_WARNING,
        'options' => [
            'title' => 'Oops...',
            'text' => 'Something went wrong!',
            'footer' => '<a href>Why do I have this issue?</a>'
        ]
]);

** Javascrip Confrim Dialog Override**

The native javascript confirm dialog is overridden by default, to disable this override, use the following configuration in config.php or web,php(in advanced template):

'assetManager' => [
    'bundles' => [
        'kamran377\yii2-sweetalert2\SweetAlertAsset' => [
            'overrideConfirm' => false
        ]
    ]
]

Sweet Alert2 Options

You can find them on the sweetalert2 homepage