phpnt / awesome-bootstrap-checkbox
Yii2 Awesome Bootstrap Checkbox
0.0.1
2016-07-04 11:58 UTC
Requires
- php: >=5.4.0
- bower-asset/awesome-bootstrap-checkbox: *
- phpnt/font-awesome: ^0.0.1
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-09-27 01:59:08 UTC
README
描述
允许使用样式化的复选框和单选按钮。
DEMO
- 支持phpNT
社交媒体
安装
php composer.phar require "phpnt/awesome-bootstrap-checkbox" "*"
或
composer require phpnt/awesome-bootstrap-checkbox
或添加到composer.json文件
"phpnt/awesome-bootstrap-checkbox": "*"
视图
<?php use yii\bootstrap\Html; use yii\bootstrap\ActiveForm; use phpnt\awesomeBootstrapCheckbox\AwesomeBootstrapCheckboxAsset; AwesomeBootstrapCheckboxAsset::register($this); // Теперь, все элементы input с типом checkbox или radio, обернутые в класс checkbox будут стилизованые // массив элементов $items = [ 1 => 'Апельсин', 2 => 'Бочка', 3 => 'Велосипед', 4 => 'Гризли', 5 => 'Дом', ]; // Использование в активной форме $form = ActiveForm::begin(); // Вертикальное расположение echo $form->field($model, 'id') ->checkboxList( $items, [ 'item' => function ($index, $label, $name, $checked, $value){ return '<div class="checkbox-info checkbox"> <input type="checkbox" id="check-'.$index.'" name="Model['.$name.'][]" value="'.$value.'" checked> <label for="check-'.$index.'">'.$label.'</label> </div>'; } ]); // Горизонтальное расположение echo $form->field($model, 'id') ->radioList( $items, [ 'class' => 'radio radio-success radio-inline', 'item' => function ($index, $label, $name, $checked, $value){ return '<input type="radio" id="check-h-'.$index.'" name="Model['.$name.'][]" value="0"> <label for="check-h-'.$index.'">'.$label.'</label>'; } ])->inline(true); ActiveForm::end(); //Использование без активной формы // Вертикальное расположение Html::checkboxList('item', null, $items, [ 'class' => 'checkbox checkbox-inline checkbox-warning', 'item' => function ($index, $label, $name, $checked, $value){ return '<input type="checkbox" id="check-n-'.$index.'" name="Model['.$name.'][]" value="'.$value.'" checked> <label for="check-n-'.$index.'">'.$label.'</label>'; } ]); // Горизонтальное расположение Html::radioList('item', null, $items, [ 'class' => 'radio radio-danger', 'item' => function ($index, $label, $name, $checked, $value){ return '<div><input type="radio" id="check-n2-'.$index.'" name="Model['.$name.'][]" value="'.$value.'"> <label for="check-n2-'.$index.'">'.$label.'</label></div>'; } ]); ?>