dbfernandes/yii2-icomp-toggle

安装: 86

依赖者: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 1

类型:yii2-extension

1.0.1 2017-07-14 08:19 UTC

This package is auto-updated.

Last update: 2024-09-20 03:02:55 UTC


README

Yii2 扩展,用于渲染 Bootstrap 切换小部件而不是复选框。

Screenshot

http://www.bootstraptoggle.com/

安装

安装此扩展的首选方式是通过 composer

运行以下命令:

$ php composer.phar require dbfernandes/yii2-icomp-toggle dev-master

或将以下内容添加到 composer.json 文件的 require 部分中:

"dbfernandes/yii2-icomp-toggle": "dev-master"

使用方法

在活动表单中

use dbfernandes\icomp\ICompToggleWidget;

//...
echo $form->field($model, 'attribute')->widget(ICompToggleWidget::className());
//...

独立小部件

use dbfernandes\icomp\ICompToggleWidget;

//...
IcompToggleWidget::widget([
    'name' => 'is_enabled',
    'value' => false,
]);
//...

选项

ICompToggleWidget::widget([

    /**
     * Wrapper tag name. If set to false no tag will be rendered
     */
    'container' => 'div',

    /**
     * Wrapper HTML attributes
     */
    'containerOptions' => [],
    
    /**
     * Label when checkbox is checked
     */
    'labelEnabled' => 'Yes',
    
    /**
     * Label when checkbox is not checked
     */
     'labelDisabled' => 'No',
     
     /**
      * Additional javascript options to Bootstrap Toggle plugin 
      */
      'pluginOptions' => [],
]);