ofilin/yii2-sweetalert

SweetAlert Asset

Installs: 6

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:yii2-extension

0.1 2019-06-27 13:36 UTC

This package is auto-updated.

Last update: 2024-08-28 22:12:04 UTC


README

SweetAlert2

yii2-sweetalert

This asset override standard JavaScript yii.confirm method. Plugin SweetAlert2

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist ofilin/yii2-sweetalert "*"

or add

"ofilin/yii2-sweetalert": "*"

to the require section of your composer.json file and run composer update

Configure

In your Asset file add this SweetAlertAsset:

public $depends = [
        'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapAsset',
        \ofilin\sweetalert\SweetAlertAsset::class,
    ];

or register in view file:

\ofilin\sweetalert\SweetAlertAsset::register($this);

Show alerts:

Basic alert

<?= \ofilin\sweetalert\SweetAlertWidget::widget(['pluginOptions' => [
    'type' => 'error',
    'title'=>'Oops...',
    'text' => 'Something went wrong!',
]]) ?>

Flash alert:

// in controller
Yii::$app->session->setFlash('success', "Статья сохранена");

<!-- in view/layout -->
<?= \ofilin\sweetalert\SweetAlertWidget::widget(['isFlash' => true]) ?>