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 441

Dependents: 0

Suggesters: 0

Security: 0

Stars: 6

Watchers: 2

Forks: 1

Open Issues: 0

Language:JavaScript

Type:yii2-extension

2.0.2 2019-07-18 20:00 UTC

This package is auto-updated.

Last update: 2024-04-19 05:46:58 UTC


README

Latest Version Software License Total Downloads

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