1. Go to this page and download the library: Download yii2mod/yii2-sweet-alert 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/ */
yii2mod / yii2-sweet-alert example snippets
Yii::$app->session->setFlash('success', 'This is the message');
echo Alert::widget();
// A replacement for the "prompt" function
echo \yii2mod\alert\Alert::widget([
'useSessionFlash' => false,
'options' => [
'timer' => null,
'type' => \yii2mod\alert\Alert::TYPE_INPUT,
'title' => 'An input!',
'text' => "Write something interesting",
'confirmButtonText' => "Yes, delete it!",
'closeOnConfirm' => false,
'showCancelButton' => true,
'animation' => "slide-from-top",
'inputPlaceholder' => "Write something"
],
'callback' => new \yii\web\JsExpression(' function(inputValue) {
if (inputValue === false) return false;
if (inputValue === "") {
swal.showInputError("You need to write something!");
return false;
}
swal("Nice!", "You wrote: " + inputValue, "success");
}')
]);