yii2-simple-dual-listbox Simple dual listbox for Yii framework 2.0 or later

Description

edwinhaq\simpleduallistbox\SimpleDualListbox widget is a simple way to control listbox items

Requirements
Yii Version 2.0.0 or later
Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist edwinhaq/yii2-simple-dual-listbox "*"

or add

"edwinhaq/yii2-simple-dual-listbox": "*"

to the require section of your composer.json file. Usage

Once the extension is installed, simply use it in your code by:

use edwinhaq\simpleduallistbox\SimpleDualListbox;
	
// ... Form definition

$items = ['1' => 'GSM', '2' => 'G.711u', '3' => 'G.711a', '4' => 'G.729'];

$options = [];
$options['size'] = 10;
$options['style'] = 'width:200px';
$options['options'] = [];	
	
$clientOptions = [];
$clientOptions['availableListboxPosition'] = "left";
$clientOptions['upButtonText'] = "UP";	
$clientOptions['addButtonText'] = "ADD";				
$clientOptions['addAllButtonText'] = "ADDALL";			
$clientOptions['remAllButtonText'] = "REMALL";			
$clientOptions['remButtonText'] = "REM";				
$clientOptions['downButtonText'] =  "DOWN";				
$clientOptions['selectedLabel'] =  "Selected";			
$clientOptions['availableLabel'] = "Available";			

$widgetOptions = [];
$widgetOptions['label'] = 'InputLabel'; // Ignored when model is used
$widgetOptions['name'] = 'InputName'; // Ignored when model is used
$widgetOptions['hint'] = 'Hint'; // Ignored when model is used
$widgetOptions['selection'] = [1,2]; // Ignored when model is used
$widgetOptions['id'] = 'Input ID'; // Optional
$widgetOptions['template'] = '{label}{listbox}{hint}'; 
$widgetOptions['useGroupDiv'] = true; // Wrap element in a div tag: <div class="form-group"> ... </div>, 
$widgetOptions['items'] = $items;
$widgetOptions['options'] = $options;
$widgetOptions['clientOptions'] = $clientOptions; 
/*
* With model
*/
$model->attribute = [1,2,3];
			
echo $form->field($model, 'attribute')->widget(SimpleDualListbox::className(), $widgetOptions);

/*
* Without model
*/
			
echo SimpleDualListbox::widget($widgetOptions);

// ... End form definition	

Simple Dual Listbox

MORE INFO

0 0
1 follower
0 downloads
Yii Version: 2.0
License: MIT
Category: User Interface
Developed by: edwinhaq
Created on: May 30, 2017
Last updated: 6 years ago

Related Extensions