wbraganca / yii2-selectivity
The yii2-selectivity is a Yii 2 wrapper for [selectivity](https://arendjr.github.io/selectivity/). A modular and light-weight selection library for jQuery and Zepto.js.
Installs: 3 523
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 1
Open Issues: 0
Language:JavaScript
Type:yii2-extension
Requires
- yiisoft/yii2: ~2.0.14
This package is auto-updated.
Last update: 2024-11-19 07:05:05 UTC
README
Install
Via Composer
$ composer require wbraganca/yii2-selectivity
or add
"wbraganca/yii2-selectivity": "~2.0.1"
to the require section of your composer.json
file.
Usage
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