chosen Anouther chosen extension, provides easy to use InputWidget

  1. Requirements
  2. Usage
  3. Also you can use it like CHtml helper
  4. Changes
  5. Resources

This extension is a wrapper for Chosen JavaScript plugin which makes long, unwieldy select boxes much more user-friendly.

Requirements

Tested with Yii 1.1.10, but should work with previous versions too

Usage

  1. Checkout source code to your project, for example to ext.chosen
  2. Use it, as any input widget

Example:

$this->widget('ext.chosen.Chosen',array(
   'name' => 'inputName', // input name
   'value' => '2', // selection
   'data' => array( // list of select options
       '1'=>'Option 1',
       '2'=>'Option 2',
       '3'=>'Option 3',
       '4'=>'Option 4',
    ),
));

Also you can use it like CHtml helper

Before this import ext.chosen.Chosen, you can add it to config/main.php or call Yii::import('ext.chosen.Chosen') before usage.

Chosen::dropDownList($name, $select, $data, $htmlOptions);
Chosen::activeDropDownList($model, $attribute, $data, $htmlOptions);
Chosen::multiSelect($name, $select, $data, $htmlOptions);
Chosen::activeMultiSelect($model, $attribute, $data, $htmlOptions);

Also if you need to specify some options for widget when using helper - you can use options key, for example:

echo Chosen::multiSelect($name, $select, $data,
    array(
       'data-placeholder' => 'Tags',
       'options'=>array(
          'maxSelectedOptions' => 3,
          'displaySelectedOptions' => true,
    )));

Changes

  • March 25, 2014 Upgrade chosen to 1.1.0
  • October 27, 2013 Add support for new configuration options
  • October 19, 2013 Upgrade chosen to 1.0.0
  • June 25, 2013 Upgrade chosen to 0.10.0, added searchContains option.
  • March 19, 2013 Allow to set placeholder through "data-placeholder" in htmlOptions, when using Chosen::* methods.
  • February 13, 2013 Fixed bug when resolving value by attribute name
  • December 12, 2012 Update chosen to version 0.9.11
  • August 5, 2012 Fixed bug when using as input widget(not like CHtml helper)
  • July 23, 2012 Fixed bug in Chosen::activeMultiSelect

Resources

13 0
23 followers
2 064 downloads
Yii Version: 1.1
License: MIT
Category: User Interface
Developed by: Bogdan Savluk
Created on: Jul 8, 2012
Last updated: 10 years ago

Downloads

show all

Related Extensions