PHP code example of 2amigos / yii2-switch-widget

1. Go to this page and download the library: Download 2amigos/yii2-switch-widget library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

2amigos / yii2-switch-widget example snippets

 
<?= \dosamigos\switchinput\SwitchRadio::widget([
    'name' => 'shape',
    'inline' => false,
    'items' => [
        [
            'label' => 'best',
            'value' => 100,
            'options' => ['data-size' => 'mini']
        ],
        20 => 'good',
        40 => 'superior',
        50 => 'master'
    ],
    'labelOptions' => ['style' => 'font-size:16px']
]);
 
<?= $form->field($model, 'validated')->widget(SwitchBox::className(),[
    'options' => [
        'label' => false
    ],
    'clientOptions' => [
        'size' => 'large',
        'onColor' => 'success',
        'offColor' => 'danger'
    ]
]);


use dosamigos\switchinput\SwitchBox;


use dosamigos\switchinput\SwitchRadio;
bash 
./vendor/bin/php-cs-fixer fix ./src --config .php_cs