2017 © Pedro Peláez
 

yii2-extension yii2-awesome-bootstrap-checkbox

Yii2 widget for awesome-bootstrap-checkbox

image

bookin/yii2-awesome-bootstrap-checkbox

Yii2 widget for awesome-bootstrap-checkbox

  • Monday, July 25, 2016
  • by bookin
  • Repository
  • 1 Watchers
  • 4 Stars
  • 6,743 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 1 Versions
  • 7 % Grown

The README.md

Yii2 widget - Awesome Bootstrap Checkbox

This yii2 extension is a wrapper for the Awesome Bootstrap Checkbox & Radios plugin, (*1)

Code Climate Total Downloads Latest Unstable Version License, (*2)

Installation

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)

Requires

This extension require awesome-bootstrap-checkbox, yii2-bootstrap and font-awesome, (*7)

Usage

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'
    ]
]);

Bitdeli Badge, (*8)

The Versions

25/07 2016

dev-master

9999999-dev

Yii2 widget for awesome-bootstrap-checkbox

  Sources   Download

BSD-3-Clause

The Requires