1. Go to this page and download the library: Download phpnt/bootstrap-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/ */
phpnt / bootstrap-select example snippets
use yii\bootstrap\Html;
use yii\bootstrap\ActiveForm;
use phpnt\bootstrapSelect\BootstrapSelectAsset;
BootstrapSelectAsset::register($this);
// теперь, все элементы, которые имеют класс selectpicker, будут стилизованными выпадающими списками
// массив элементов
$items = [
1 => 'Апельсин',
2 => 'Бочка',
3 => 'Велосипед',
4 => 'Гризли',
5 => 'Дом',
6 => 'Енот',
7 => 'Ежкина мать',
8 => 'Жигули',
9 => 'Зуб',
10 => 'Ирригация'
];
// Использование в активной форме
$form = ActiveForm::begin();
echo $form->field($model, 'id')->dropDownList($items, [
'class' => 'form-control selectpicker',
'data' => [
'style' => 'btn-success',
'live-search' => 'false',
'size' => 7,
'title' => 'Ничего не выбрано'
]]);
echo $form->field($model, 'id')->dropDownList($items, [
'class' => 'form-control selectpicker',
'data' => [
'style' => 'btn-primary',
'live-search' => 'true',
'size' => 7,
'title' => 'Ничего не выбрано',
],
]);
echo $form->field($model, 'id')->dropDownList($items, [
'class' => 'form-control selectpicker',
'multiple' => true,
'data' => [
'style' => 'btn-warning',
'live-search' => false,
'size' => 7,
],
]);
ActiveForm::end();
// Использование без активной формы
echo Html::dropDownList('item', null, $items, [
'class' => 'form-control selectpicker',
'data' => [
'style' => 'btn-info',
'live-search' => 'false',
'size' => 7,
'title' => 'Ничего не выбрано',
]
]);
echo Html::dropDownList('item', null, $items, [
'class' => 'form-control selectpicker',
'data' => [
'style' => 'btn-default',
'live-search' => 'true',
'size' => 7,
'title' => 'Ничего не выбрано',
]
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.