2017 © Pedro Peláez
 

yii2-extension yii2-selectize

selectize.js wrapper for yii2

image

yii2mod/yii2-selectize

selectize.js wrapper for yii2

  • Monday, August 21, 2017
  • by disem
  • Repository
  • 4 Watchers
  • 20 Stars
  • 3,385 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 9 Forks
  • 0 Open issues
  • 5 Versions
  • 12 % Grown

The README.md

, (*1)

Yii2 Selectize Widget


Widget based on selectize.js extension https://selectize.github.io/selectize.js/, (*2)

Latest Stable Version Total Downloads License Build Status, (*3)

Installation

The preferred way to install this extension is through composer., (*4)

Either run, (*5)

php composer.phar require --prefer-dist yii2mod/yii2-selectize "*"

or add, (*6)

"yii2mod/yii2-selectize": "*"

to the require section of your composer.json., (*7)

Usage

Once the extension is installed, simply add widget to your page as follows:, (*8)

1) Tagging input:, (*9)

echo $form->field($model, "attribute")->widget(Selectize::className(), [
        'pluginOptions' => [
            'persist' => false,
            'createOnBlur' => true,
            'create' => true
        ]
]); 

2) Select input:, (*10)

echo $form->field($model, "attribute")->widget(Selectize::className(), [
        'items' => [
            'Yes',
            'No'
        ],
        'pluginOptions' => [
            'persist' => false,
            'createOnBlur' => true,
            'create' => true
        ]
]); 

3) Tagging input with remote source and default values(If you want render select input, just setup items property):, (*11)

Setup view file:, (*12)

// setup the following to get the existing data from database
$model->attribute = 'first, last';

// or if the data is an array you can preselect the tags like this
$model->attribute = implode(', ', ["first", "last"]);

echo $form->field($model, "attribute")->widget(Selectize::className(), [
         'url' => '/site/search',
         'pluginOptions' => [
            'valueField' => 'name',
            'labelField' => 'name',
            'searchField' => ['name'],
            'persist' => false,
            'createOnBlur' => true,
            'create' => true
        ]
]);
 ```

 **Your action must return data in the json format, for example:**

```php
  public function actionSearch($query = null)
  {
      Yii::$app->response->format = Response::FORMAT_JSON;
      return [
          ['name' => 'Search Item 1'],
          ['name' => 'Search Item 2'],
      ];
  }

4) Usage widget with plugins:, (*13)

echo Selectize::widget([
        'name' => 'tag-selectize',
        'options' => [
             'data-data' => $values ? Json::encode($values) : null // Set default values
        ],
        'pluginOptions' => [
             // define list of plugins 
            'plugins' => ['drag_drop', 'remove_button'],
            'persist' => false,
            'createOnBlur' => true,
            'create' => true
        ]
 ]);

Select Options

You can find them on the options page, (*14)

Support us

Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff., (*15)

The Versions

21/08 2017

dev-master

9999999-dev

selectize.js wrapper for yii2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Igor Chepurnoy

yii2 selectize yii2 selectize.js yii2 select yii2 tagging

05/03 2017

1.3

1.3.0.0

selectize.js wrapper for yii2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Igor Chepurnoy

yii2 selectize yii2 selectize.js yii2 select yii2 tagging

16/09 2016

1.2

1.2.0.0

selectize.js wrapper for yii2

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

yii2 selectize yii2 selectize.js yii2 select yii2 tagging

31/08 2016

1.1

1.1.0.0

selectize.js wrapper for yii2

  Sources   Download

MIT

The Requires

 

by Igor Chepurnoy

yii2 selectize yii2 selectize.js yii2 select yii2 tagging

17/06 2015

1.0

1.0.0.0

selectize.js wrapper for yii2

  Sources   Download

MIT

by Igor Chepurnoy

yii2 module