Giter Site home page Giter Site logo

2amigos / yii2-select2-widget Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 6.0 54 KB

Select 2 jQuery plugin for Yii2 with Bootstrap theme capabilities

Home Page: http://2amigos.us

License: Other

PHP 95.54% CSS 4.46%
2amigos select2 widget yii2 bootstrap

yii2-select2-widget's Introduction

Select2 Widget for Yii2

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

Select2 gives you a customizable select box with support for searching, tagging, remote data sets, infinite scrolling, and many other highly used options.

Install

Via Composer

$ composer require 2amigos/yii2-select2-widget

Usage

The Widget comes in two flavors, one for the classic and the bootstrap. The widgets, apart from the bootstrap one that requires some tweaks, are mostly configured throughout the clientOptions and clientEvents. Attributes that hold the configuration of the plugin and its events respectively.

For that reason, we highly recommend you to visit the Select2 Documentation for the possible options available on Select2 and Select2 Bootstrap Theme to check all the possible display options regarding Select2 with this theme.

Note We are in the process to create a website that will demo all our widgets, including this. The following are some basic samples to get you started. On the website, demos will be extensive and showing all possible configuration options.

Using Select2Widget

use dosamigos\select2\Select2:


// with \yii\bootstrap\ActiveForm;
echo $form
    ->field($model, 'attribute')
    ->widget(
        Select2::class, 
        [
            'items' => $data, // $data should be the same as the items provided to a regular yii2 dropdownlist
            'clientOptions' => ['theme' => 'classic']
        ]
    );
    
// as widget 
echo Select2::widget([
    'name' => 'my-name',
    'value' => 'my-value',
    'clientOptions' => [
        'maximumInputLength' => 20
    ]
]); 

Using Select2BootstrapWidget

use dosamigos\select2\Select2Bootstrap:

// displaying the select2 with prepended addon
echo $form
    ->field($model, 'attribute')
    ->widget(
        Select2Bootstrap::class, 
        [
            'items' => $data, // $data should be the same as the items provided to a regular yii2 dropdownlist
            'template' => '<div class="input-group">' .
                  '<span class="input-group-btn">' .
                  '<button class="btn btn-default" type="button" data-select2-open="multi-prepend-append">' .
                  'State' .
                  '</button>' .
                  '</span>' .
                  '{input}' .
                   '<span class="input-group-addon">Append</span>' .
                   '</div>'
        ]
    );
    
// as widget 
echo Select2Bootstrap::widget([
    'name' => 'my-name',
    'value' => 'my-value',
    'clientOptions' => [
        'maximumInputLength' => 20
    ]
]); 

Testing

$ phpunit

Using code fixer

We have added a PHP code fixer to standardize our code. It includes Symfony, PSR2 and some contributors rules.

./vendor/bin/php-cs-fixer fix ./src --config .php_cs

Contributing

Please see CONTRIBUTING for details.

Credits

License

The BSD License (BSD). Please see License File for more information.


Custom Software | Web & Mobile Development
www.2amigos.us

yii2-select2-widget's People

Contributors

tonydspaniard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

yii2-select2-widget's Issues

Problem wher composer install

When I make "composer require 2amigos/yii2-select2-widget"

Problem 1
- Installation request for 2amigos/yii2-select2-widget ^0.1.2 -> satisfiable by 2amigos/yii2-select2-widget[0.1.2].
- 2amigos/yii2-select2-widget 0.1.2 requires bower-asset/select2-bootstrap-theme ~0.1.0-beta.10 -> satisfiable by bower-asset/select2-bootstrap-theme[0.1.0-beta.10] but these conflict with your requirements or minimum-stability.

Fix placeholder issue

What steps will reproduce the problem?

Setting allowClear without placeholder

What is the expected result?

allow clear and display placeholder

What do you get instead?

nothing

A mechanism to get the prompt value from the options should be in place + adding the automatic option to fix that issue when only allowClear has been set

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.