toxor88 / yii2-widget-switchery
增强版的 Yii2 对 Switchery.js 插件的包装。
1.0
2015-05-19 16:44 UTC
Requires
- php: >=5.4.0
- bower-asset/switchery: 0.8.*
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-09-24 18:48:35 UTC
README
iOS Switchery 滑块(http://abpetkov.github.io/switchery/)
安装
安装此扩展的首选方式是通过 composer。请检查此扩展的composer.json 文件以了解其要求和依赖项。
安装方法如下:
$ php composer.phar require toxor88/yii2-widget-switchery "*"
或者将以下内容添加到您的 composer.json
文件的 require
部分:
"toxor88/yii2-widget-switchery": "*"
toxor88/yii2-widget-switchery
演示
您可以参考扩展的详细文档和演示。
用法
use toxor88\switchery\Switchery; use yii\web\JsExpression; // usage without model echo '<label>Can do something?</label>'; echo Switchery::widget([ 'name' => 'can_do_something', 'clientOptions' => [ 'color' => '#64bd63', 'secondaryColor' => '#dfdfdf', 'jackColor' => '#fff', 'jackSecondaryColor' => null, 'className' => 'switchery', 'disabled' => false, 'disabledOpacity' => 0.5, 'speed' => '0.1s', 'size' => 'default', ], 'clientChangeEvent' => new JsExpression('function() { alert("checked: " + this.checked); }'), ]); // usage with model $form->model($model, 'attribute')->widget(Switchery::className(), [ /* widget options... */ ]); // if you use the defualt ActiveField template, there can be multiple labels. To avoid it use: // the label displays after the slider: $form->model($model, 'attribute')->widget(Switchery::className(), [ /* widget options... */ ])->label(false); // the label displays before the slider: $form->model($model, 'attribute')->widget(Switchery::className(), [ 'options' => 'label' => null ])->label('label text or inherited from model');
许可协议
yii2-widget-switchery 遵循 BSD 3-Clause 许可协议。有关详细信息,请参阅捆绑的 LICENSE
文件。