PHP code example of consultnn / yii2-select2
1. Go to this page and download the library: Download consultnn/yii2-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/ */
consultnn / yii2-select2 example snippets
php composer.phar
echo $form->field($model, 'attribute')->widget(
\consultnn\select2\Select2::className(),
[
'options' => [
'multiple' => true
],
'items' => $items, // @see Html::dropDownList() $items argument
'pluginOptions' => [
'ajax' => [
'url' => Url::toRoute(['controller/autoComplete']), // return Json::encode(['results' => [['id' => 1, 'text' => 'text1'], ...]]);
'dataType' => 'json'
]
]
]
);