dev-master
9999999-devYii2 widget for awesome-bootstrap-checkbox
BSD-3-Clause
The Requires
- php >=5.4.0
- yiisoft/yii2 *
- bower-asset/awesome-bootstrap-checkbox 0.3.*
- yiisoft/yii2-bootstrap *
- fortawesome/font-awesome *
by Anton
Yii2 widget for awesome-bootstrap-checkbox
This yii2 extension is a wrapper for the Awesome Bootstrap Checkbox & Radios plugin, (*1)
The preferred way to install this extension is through composer., (*3)
To install, either run, (*4)
$ php composer.phar require bookin/yii2-awesome-bootstrap-checkbox "@dev"
or add, (*5)
"bookin/yii2-awesome-bootstrap-checkbox": "@dev"
to the require
section of your composer.json
file., (*6)
This extension require awesome-bootstrap-checkbox, yii2-bootstrap and font-awesome, (*7)
use bookin\aws\checkbox\AwesomeCheckbox; // ActiveForm & model - default checkbox echo $form->field($model, 'attribute')->widget(AwesomeCheckbox::classname()); // ActiveForm & model - change type to radio echo $form->field($model, 'attribute')->widget(AwesomeCheckbox::classname(),[ 'type'=>AwesomeCheckbox::TYPE_RADIO, // default type AwesomeCheckbox::TYPE_CHECKBOX ]); // ActiveForm & model - change style (you can use STYLE_DEFAULT, STYLE_PRIMARY, STYLE_SUCCESS, STYLE_INFO, STYLE_WARNING, STYLE_DANGER - it is bootstrap colors) echo $form->field($model, 'attribute')->widget(AwesomeCheckbox::classname(),[ 'type'=>AwesomeCheckbox::TYPE_RADIO, 'style'=>AwesomeCheckbox::STYLE_SUCCESS, ]); // ActiveForm & model - circle checkbox with style echo $form->field($model, 'attribute')->widget(AwesomeCheckbox::classname(),[ 'type'=>AwesomeCheckbox::TYPE_CHECKBOX, //optional string default type TYPE_CHECKBOX 'style'=>[ AwesomeCheckbox::STYLE_CIRCLE, AwesomeCheckbox::STYLE_SUCCESS ], ]); // ActiveForm & model - checkbox list echo $form->field($model, 'attribute')->widget(AwesomeCheckbox::classname(),[ 'type'=>AwesomeCheckbox::TYPE_CHECKBOX, //optional string default type TYPE_CHECKBOX 'style'=>AwesomeCheckbox::STYLE_PRIMARY, 'list'=>[ // array data 'id1'=>'item1', 'id2'=>'item2' ] ]); // ActiveForm & model - radio list echo $form->field($model, 'attribute')->widget(AwesomeCheckbox::classname(),[ 'type'=>AwesomeCheckbox::TYPE_RADIO, 'style'=>AwesomeCheckbox::STYLE_PRIMARY, 'list'=>[ // array data 'id1'=>'item1', 'id2'=>'item2' ] ]); // ActiveForm & model - disabled option echo $form->field($model, 'attribute')->widget(AwesomeCheckbox::classname(),[ 'options'=>[ 'disabled'=>true ] ]); // ActiveForm & model - set value and uncheck echo $form->field($model, 'attribute')->widget(AwesomeCheckbox::classname(),[ 'options'=>[ 'value'=>5, 'uncheck'=>7 ] ]); // By name - default checkbox echo AwesomeCheckbox::widget([ 'name'=>'test', 'options'=>[ 'label'=>'Checkbox' ] ]); // By name - default radio echo AwesomeCheckbox::widget([ 'name'=>'test', 'type'=>AwesomeCheckbox::TYPE_RADIO, 'options'=>[ 'label'=>'Checkbox' ] ]); // By name - change style echo AwesomeCheckbox::widget([ 'name'=>'test', 'type'=>AwesomeCheckbox::TYPE_RADIO, 'style'=>AwesomeCheckbox::STYLE_PRIMARY, 'options'=>[ 'label'=>'Checkbox' ] ]); // By name - circle checkbox with style echo AwesomeCheckbox::widget([ 'name'=>'test', 'type'=>AwesomeCheckbox::TYPE_RADIO, 'style'=>[AwesomeCheckbox::STYLE_CIRCLE, AwesomeCheckbox::STYLE_PRIMARY], 'options'=>[ 'label'=>'Checkbox' ] ]); // By name - checked echo AwesomeCheckbox::widget([ 'name'=>'test', 'checked' => true, 'options'=>[ 'label'=>'Checkbox' ] ]); // By name - disabled echo AwesomeCheckbox::widget([ 'name'=>'test', 'checked' => true, 'options'=>[ 'disabled'=>true, 'label'=>'Checkbox' ] ]); // By name - list checkbox echo AwesomeCheckbox::widget([ 'name'=>'test', 'list'=>[ // array data 'id1'=>'item1', 'id2'=>'item2' ], 'options'=>[ 'label'=>'Checkbox' ] ]); // By name - list radio echo AwesomeCheckbox::widget([ 'name'=>'test', 'type'=>AwesomeCheckbox::TYPE_RADIO, 'list'=>[ // array data 'id1'=>'item1', 'id2'=>'item2' ], 'options'=>[ 'label'=>'Checkbox' ] ]); // By name - checked list checkbox echo AwesomeCheckbox::widget([ 'name'=>'test', 'checked' => 'id1', // you can use string or array with values for list 'list'=>[ // array data 'id1'=>'item1', 'id2'=>'item2' ], 'options'=>[ 'label'=>'Checkbox' ] ]);
Yii2 widget for awesome-bootstrap-checkbox
BSD-3-Clause