PHP code example of kak / select2

1. Go to this page and download the library: Download kak/select2 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/ */

    

kak / select2 example snippets



<?= \kak\widgets\select2\Select2::widget([
   'toggleEnable' => false,            // visible select all/unselect all
   'selectLabel' => 'select all',
   'unselectLabel' => 'unselect all',
   'options' => [
        'data-scroll-height' => 150,  // auto scroll
        'data-item-width'    => 100,  // 100|auto
   ]
   'multiple' => true,
   'value' => ['val1','val2'],
   'name' => 'inputName',
   'items' => [
        'val1' => 'options1',
        'val2' => 'options2',
        'val3' => 'options3',
        'val4' => 'options4',
   ],
]); 


<?= $form->field($model, 'list')->widget('\kak\widgets\select2\Select2', [
    'items' => [
        'val1' => 'options1',
        'val2' => 'options2',
        'val3' => 'options3',
        'val4' => 'options4',
    ],
    'options' => [
        'class' => 'myCssClass'
    ],
    'clientOptions' => [],   // js options select2
]) 

php composer.phar