select2 Wrapper for ivaynberg jQuery select2

  1. Requirements
  2. Usage
  3. Resources
  4. Changes

ESelect2 is a widget extension for Yii framework. This extension is a wrapper for Select2 Jquery plugin (https://github.com/ivaynberg/select2).

Requirements

  • Yii 1.1 or above (tested on 1.1.10)

Usage

  • Extract the downloaded file to your application extensions directory
  • Just place the following code inside your view file:
// Working with selector
$tags=array('Satu','Dua','Tiga');
echo CHtml::textField('test','',array('id'=>'test'));
$this->widget('ext.select2.ESelect2',array(
  'selector'=>'#test',
  'options'=>array(
    'tags'=>$tags,
  ),
));

<?php $this->widget('ext.select2.ESelect2',array(
  'name'=>'selectInput',
  'data'=>array(
    0=>'Nol',
    1=>'Satu',
    2=>'Dua',
  ),
); ?>

// Working with model
<?php $this->widget('ext.select2.ESelect2',array(
  'model'=>$model,
  'attribute'=>'attrName',
  'data'=>array(
    0=>'Nol',
    1=>'Satu',
    2=>'Dua',
  ),
); ?>


// Optgroup
$data=array(
  'one'=>array(
    '1'=>'Satu',
    '2'=>'Dua',
    '3'=>'Tiga',
  ),
  'two'=>array(
    '4'=>'Sidji',
    '5'=>'Loro',
    '6'=>'Telu',
  ),
  'three'=>array(
    '7'=>'Hiji',
    '8'=>'Dua',
    '9'=>'Tilu',
  ),
);

$this->widget('ext.select2.ESelect2',array(
  'name'=>'testing',
  'data'=>$data,
)); 


$data=array(
  '1'=>'Satu',
  '2'=>'Dua',
  '3'=>'Tiga',
);


// Multiple data
$this->widget('ext.select2.ESelect2',array(
  'name'=>'ajebajeb',
  'data'=>$data,
  'htmlOptions'=>array(
    'multiple'=>'multiple',
  ),
));

// Placeholder
$this->widget('ext.select2.ESelect2',array(
  'name'=>'asik2x',
  'data'=>$data,
  'options'=>array(
    'placeholder'=>'Keren ya?',
    'allowClear'=>true,
  ),
));
?>




Resources

Changes

  • February 15, 2013
    • Update to select2 3.3
  • November 29, 2012
    • Update to select2 3.2, supporting jQuery events, new public method init()
  • September 13, 2012
  • August 21, 2012
  • July 09, 2012
    • New public property $selector, to select any input[type=text] or other Html element
    • jQuery select2 fixes #192
  • June 20, 2012
    • Opt group and assets path fix (thanks to Porcelanosa)
  • June 19, 2012
    • Placeholder fix
36 0
76 followers
8 112 downloads
Yii Version: 1.1
License: Apache-2.0
Category: User Interface
Developed by: nk913
Created on: Jun 13, 2012
Last updated: 11 years ago

Downloads

show all

Related Extensions