PHP code example of yii-ui / yii2-materialize-select2

1. Go to this page and download the library: Download yii-ui/yii2-materialize-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/ */

    

yii-ui / yii2-materialize-select2 example snippets

 
use yiiui\yii2materializeselect2\Select2:

echo $form->field($model, 'attribute')->widget(Select2::class, [
    'items' => [1 => 'Apple', 2 => 'Banana'],
    'options' => [
        'placeholder' => 'Select your favourite',
    ],
    'clientOptions' => [
        'allowClear' => true
    ],
]);
  
Select2::widget([
    'name' => 'input-name',
    'value' => 2,
    'items' => [1 => 'Apple', 2 => 'Banana'],
    'options' => [
        'placeholder' => 'Select your favourite',
    ],
    'clientOptions' => [
        'allowClear' => true
    ],
]);