dev-master
9999999-devDual list box Widget for Yii 2
MIT
The Requires
by Geodan B.V.
by Steve Simpson
yii2 yii 2 widget duallistbox dual-list-box dual listview
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)
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)
Once the extension is installed, simply use it in your code:, (*9)
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)
[ { "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)
$('#list_regions').update({ uri: 'http://example.com/data2', });
$model = new ModelForm; $region = Region::find()->all();
$model = new ModelForm; $model->load(Yii::$app->request->post()); $region_model = Json::decode($model->list_regions);
Dual list box Widget for Yii 2
MIT
yii2 yii 2 widget duallistbox dual-list-box dual listview