siripravi/modal 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

siripravi/modal

Composer 安装命令:

composer require siripravi/modal

包简介

Extension for the Yii2 framework

README 文档

README

Description

This extension allows you to quickly add full-featured modal forms to your appllication. Main featues are:

  1. Based on bootstrap modal forms.
  2. Allows quickly add behavior to interact with viewing and updating data in modal dialogs.
  3. Catch form post events, converts them to ajax request and display results in the same modal dialog.

Installation

The preferred way to install this extension is through composer.

To install, either run

$ php composer.phar require siripravi/modal "*"

or add

"siripravi/modal": "*"

to the require section of your composer.json file.

Usage

Somewhere in the main layout

\siripravi\modal\ModalForm::widget([
    'selector' => '.modal-form',
]);

Whenever you want to add behavior to tag a, just add class 'modal-form'

    echo Html::a('Some modal action', ['controller/action'], ['class' => 'modal-form']);

To improve traffic data and error exceptions you need to control layout rendering when ajax requests. I recommend you to override default rendering in your controllers:

class Controller extends \yii\web\Controller
{
    /**
     * Exclude layout rendering when ajax requests
     */
    public function render($view, $params = [])
    {
        if (\Yii::$app->request->isAjax) {
            return $this->renderPartial($view, $params);
        }
        return parent::render($view, $params);
    }
}

Client Options

To add client options use clientOptions key. Available client options are: id, class, tabindex.

  • Id key replaces existing auto generated id attribute.
  • Class key adds classes to html class attribute.
  • Tabindex key replaces existing default tabindex html attribute (-1), when false, then no tabindex attribute appears.
\siripravi\modal\ModalForm::widget([
    'selector' => '.modal-form',
    'clientOptions' => [
        'id' => 'sample-unique-id',
        'class' => 'sample-class1 sample-class2',
        'tabindex' => false
    ]
]);

License

siripravi/modal is released under the MIT License. See the bundled LICENSE for details.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 11
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-30