wdmg / yii2-selectinput
Bootstrap3 SelectInput widget for Yii2
Installs: 1 956
Dependents: 24
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- bower-asset/bootstrap-selectinput-plugin: ^1.2.1
- yiisoft/yii2: ^2.0.33
- yiisoft/yii2-bootstrap: *
README
Yii2 SelectInput
SelectInput widget for Yii2
Requirements
- PHP 5.6 or higher
- Yii2 v.2.0.33 and newest
- Yii2 Bootstrap
- Bootstrap SelectInput
Installation
To install the widget, run the following command in the console:
$ composer require "wdmg/yii2-selectinput"
Usage
Example of standalone widget:
<?php
use wdmg\widgets\SelectInput;
...
echo SelectInput::widget([
'model' => $model,
'attribute' => 'type',
'items' => [
'value' => 'Label',
...
],
'options' => [
'class' => 'form-control'
],
'pluginOptions' => [
'dropdownClass' => '.dropdown',
'listClass' => '.dropdown-menu',
'itemClass' => '.dropdown-item',
'toggleClass' => '.btn .btn-default .dropdown-toggle',
'toggleText' => 'Dropdown',
'toggleCaret' => '<span class="caret"></span>',
'toggleChange' => true,
'autocomplete' => false,
'minInput' => 2
]
])
?>
Example of use with ActiveForm:
<?php
use wdmg\widgets\SelectInput;
...
$form = ActiveForm::begin();
...
echo $form->field($model, 'type')->widget(SelectInput::class, [
'items' => [
'value' => 'Label',
...
],
'options' => [
'class' => 'form-control'
],
'pluginOptions' => [
'dropdownClass' => '.dropdown',
'listClass' => '.dropdown-menu',
'itemClass' => '.dropdown-item',
'toggleClass' => '.btn .btn-default .dropdown-toggle',
'toggleText' => 'Dropdown',
'toggleCaret' => '<span class="caret"></span>',
'toggleChange' => true,
'autocomplete' => false,
'minInput' => 2
]
]);
...
ActiveForm::end();
?>
Options
SelectInput extends InputWidget so you can use any options available for this widget. In addition, you can use these custom options if necessary:
Status and version
- v.1.0.9 - Update dependencies
- v.1.0.8 - Fixed widget ID and init after Pjax reloading
- v.1.0.7 - Update pluginOptions and plugin version
- v.1.0.6 - Fixed deprecated class declaration
- v.1.0.5 - Update README.md. Update Yii2 version.