dbfernandes / yii2-icomp-toggle
1.0.1
2017-07-14 08:19 UTC
Requires
- bower-asset/bootstrap-toggle: ^2.2
- yiisoft/yii2: ^2.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-20 03:02:55 UTC
README
Yii2 扩展,用于渲染 Bootstrap 切换小部件而不是复选框。
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' => [], ]);
