2017 © Pedro Peláez
 

yii2-extension yii2-dual-list-box

Dual list box Widget for Yii 2

image

ssimpson/yii2-dual-list-box

Dual list box Widget for Yii 2

  • Friday, June 16, 2017
  • by ssimpson
  • Repository
  • 1 Watchers
  • 0 Stars
  • 23 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 17 Forks
  • 0 Open issues
  • 1 Versions
  • 35 % Grown

The README.md

Dual list box Widget for Yii 2

Dual list box Widget is a wrapper for Dual List Box plugin for jQuery and Bootstrap, Bootstrap Dual List Box is a dual list box implementation especially designed for Bootstrap and jQuery. This control is quite easy for users to understand and use. Also it is possible to work with very large multi-selects without confusing the user., (*1)

This version differes from the parent in that it works with json data pulls. Both the php/yii wrapper and the actual Javascript have been updated to get this working., (*2)

The MIT License (MIT), (*3)

Installation

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

Either run, (*5)

php composer.phar require --prefer-dist ssimpson/yii2-dual-list-box "dev-master"

or (if you have composer in your path), (*6)

composer require --prefer-dist ssimpson/yii2-dual-list-box "dev-master"

or add, (*7)

"ssimpson/yii2-dual-list-box": "dev-master"

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

Usage

Once the extension is installed, simply use it in your code:, (*9)

EXAMPLE

View


echo ssimpson\duallistbox\Widget::widget([ 'model' => $model, 'attribute' => 'list_regions', 'title' => 'Example Title', 'data' => $region, 'data_id'=> 'id', 'data_value'=> 'name', 'json_uri' => 'http://example.com/data', 'lngOptions' => [ 'warning_info' => 'Are you sure you want to move this many items? Doing so can cause your browser to become unresponsive.', 'search_placeholder' => 'Filter', 'showing' => ' - showing', 'available' => 'Available', 'selected' => 'Selected' ] ]);

model - model for form attribute - model attribute for form title - view name for attribute, (*10)

data - model (Region::find()->all()) OR array['id'=>1,'name'=>'']; This is a change from the upstream project. data_id - name attribute for id data_value - name attribute for value, (*11)

sample json data


[ { "index": 0, "name": "Peters Sloan", "company": "Kongle", "email": "peterssloan@kongle.com", "selected": true }, { "index": 1, "name": "Bailey Hoffman", "company": "Centrexin", "email": "baileyhoffman@centrexin.com" }, { "index": 2, "name": "Christine Hahn", "company": "Geoform", "email": "christinehahn@geoform.com", "selected": false } ]

in this example, only Peters Sloan would be selected by default, (*12)

To refresh the data or use a different data source

    $('#list_regions').update({
        uri: 'http://example.com/data2',
    });

Controller VIEW

        $model = new ModelForm;

        $region = Region::find()->all();

Controller SAVE

$model = new ModelForm;
$model->load(Yii::$app->request->post());
$region_model = Json::decode($model->list_regions);

The Versions

16/06 2017

dev-master

9999999-dev

Dual list box Widget for Yii 2

  Sources   Download

MIT

The Requires

 

by Steve Simpson

yii2 yii 2 widget duallistbox dual-list-box dual listview