2017 © Pedro Peláez
 

library yii2-select

Yii2 wrapper for the Select2 javascript widget

image

enigmatix/yii2-select

Yii2 wrapper for the Select2 javascript widget

  • Saturday, March 24, 2018
  • by enigmatix
  • Repository
  • 1 Watchers
  • 0 Stars
  • 164 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 17 Versions
  • 20 % Grown

The README.md

yii2-select2

Yii2 wrapper for the Select2 javascript widget., (*1)

This library makes the popular Select2 widget available for easy use in Yii2 projects within an ActiveForm. Please note that you cannot currently use this library to create a standalone Select2 widget without using an ActiveForm., (*2)

This widget is intentionally light on proprietary code, and instead favours existing Yii2 objects, classes and helpers where they are provided. It also provides a passthrough mechanism so you can use the full Select2 range of options without having to rely on support being manually added to this php widget., (*3)

REQUIREMENTS

The minimum requirement by this library is:, (*4)

  1. your Web server supports PHP 5.4.0
  2. you have Yii2 installed
  3. You have correctly configured the composer fxp plugin as per the original Yii2 installation instructions

INSTALLATION

composer  require enigmatix/yii2-select "*"

GETTING STARTED

use enigmatix/yii2select/Select2;

$dropdownList = ['Yes' => 'Yes', 'No'];

<?= $form->field($model, 'your_field_name')->widget(Select2::className(), 
   ['list' => $dropdownList]) ?>

MULTIPLE SELECTION BOX

You can set additional attributes for the 'select' html element by passing values into the 'fieldOptions', (*5)

<?= $form->field($model, 'your_field_name')->widget(Select2::className(), 
   [
        'list' => $dropdownList,
        'fieldOptions' => [
            'multiple' => true
        ]
   ]) ?>

ADVANCED USAGE

If you need to pass javascript expressions (functions or anything more complex than a string you will need to use an instance of yii\web\JsExpression to ensure the resulting config is encoded correctly. See http://www.yiiframework.com/doc-2.0/yii-web-jsexpression.html for more details: eg, (*6)

$ajaxDataFunction = new JsExpression("function (term, page) {return {q: term,};}")

<?= $form->field($model, 'your_field_name')->widget(Select2::className(), 
 [
    'list' => $dropdownList
    'pluginOptions => [
        'ajax' => [
            'data => $ajaxDataFunction,            
       ]
 ]) ?>

USING NATIVE SELECT2 FEATURES

As per the original Select2 docs found here: https://select2.github.io/ you can implement any of these features via the pluginOptions array. The array you build is passed through and JSON encoded as is, and will override any defaults within the widget itself., (*7)

CONTRIBUTIONS

If you would like to contribute to this codebase, please make a pull request or report an issue. The types of contributions that will be most useful are:, (*8)

  1. adding php abstractions for new features
  2. refining the ajax support (not currently supported)
  3. coding practice feedback and better customisability and usability

But of course all feedback is welcome :)., (*9)

The Versions

24/03 2018

dev-master

9999999-dev

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

24/03 2018

2.2.3

2.2.3.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

24/03 2018

2.2.2

2.2.2.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

26/03 2017

2.2.1

2.2.1.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

10/03 2017

2.2.0

2.2.0.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

03/03 2017

2.1.2

2.1.2.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

27/02 2017

2.1.1

2.1.1.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

16/02 2017

2.1.0

2.1.0.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

14/02 2017

2.0.0

2.0.0.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

09/09 2016

1.0.2

1.0.2.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

03/07 2016

1.0.1

1.0.1.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

03/07 2016

1.0.0

1.0.0.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

03/07 2016

0.1.4

0.1.4.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

03/07 2016

0.1.3

0.1.3.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

03/07 2016

0.1.2

0.1.2.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

03/07 2016

0.1.1

0.1.1.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield

03/07 2016

0.1.0

0.1.0.0

Yii2 wrapper for the Select2 javascript widget

  Sources   Download

MIT

The Requires

  • bower-asset/select2 4.*
  • php >=5.4.0

 

by Joel Small

framework yii2 form widget select2 activeform activefield