承接 danvick/yii2-sweetalert2 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

danvick/yii2-sweetalert2

Composer 安装命令:

composer require danvick/yii2-sweetalert2

包简介

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

README 文档

README

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 danvick/yii2-sweetalert2 "*"

or add

"danvick/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 danvick\sweetalert2\SweetAlert::widget();

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

// A replacement for the "prompt" function

echo \danvick\yii2-sweetalert2\SweetAlert::widget([
        'type' => \danvick\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' => [
        'danvick\yii2-sweetalert2\SweetAlertAsset' => [
            'overrideConfirm' => false
        ]
    ]
]

Sweet Alert2 Options

You can find them on the sweetalert2 homepage

统计信息

  • 总下载量: 219
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-18