PHP code example of ofilin / yii2-sweetalert

1. Go to this page and download the library: Download ofilin/yii2-sweetalert library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ofilin / yii2-sweetalert example snippets


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

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

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

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