Skip to content

wbraganca/yii2-selectivity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yii2-selectivity

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

About

The yii2-selectivity is a Yii 2 wrapper for Selectivity.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published