PHP code example of sunnnnn / yii2-widgets-select

1. Go to this page and download the library: Download sunnnnn/yii2-widgets-select 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/ */

    

sunnnnn / yii2-widgets-select example snippets


<?= $form->field($model, 'select')->widget(\sunnnnn\select\Select::className(), [
    '_items' => ['aaa', 'bbb', 'ccc'],
]); 

\sunnnnn\select\Select::widget([
    'name' => 'select',
    '_items' => ['aaa', 'bbb', 'ccc'],
]);

<?= $form->field($model, 'select')->widget(\sunnnnn\select\Select::className(), [
    '_items' => ['aaa', 'bbb', 'ccc'],   //选项
    '_placeholder' => '占位符',
    '_multiple' => true,  //是否多选
    '_clear' => true, //是否允许清除当前选中项 ,默认false
    '_options' => [],  //原生配置
]);