Via Composer
$ composer require wbraganca/yii2-selectivity
or add
"wbraganca/yii2-selectivity": "~2.0.1"
to the require section of your composer.json
file.
On your view file.
<?php
use wbraganca\selectivity\SelectivityWidget;
?>
<?= $form->field($model, 'city', [
'options' => ['class' => 'selectivity-container form-group']
])->widget(SelectivityWidget::classname(), [
'options' => [
'prompt' => '',
],
'pluginOptions' => [
'allowClear' => true,
'data' => ['Rio de Janeiro', 'São Paulo'],
'placeholder' => 'No city selected'
]
]) ?>
Displaying the data with appended addon
<?= $form->field($model, 'city', [
'options' => ['class' => 'selectivity-container form-group']
])->widget(SelectivityWidget::classname(), [
'options' => [
'prompt' => ''
],
'pluginOptions' => [
'allowClear' => true,
'data' => ['Rio de Janeiro', 'São Paulo'],
'placeholder' => 'No city selected'
],
'template' => '<div class="input-group">' .
'{input}' .
'<div class="input-group-append">' .
'<span class="input-group-btn">' .
'<button class="btn btn-success" type="button">' .
'<i class="fa fa-plus"></i>' .
'</button>' .
'</div>' .
'</span>' .
'</div>'
]) ?>
For more options, visit: https://arendjr.github.io/selectivity/#api
Date: 18-Jul-2019
Date: 02-Jul-2019
Date: 02-Jul-2019
Date: 08-Jun-2019
Date: 06-Jun-2019
Date: 07-Nov-2015
Date: 05-Nov-2015
Date: 04-Jul-2015
Initial release
Comments