asmselectex A progressive enhancement to select multiple form elements.

  1. Documentation
  2. Change Log

The asmSelectEx widget is implemented based this jQuery plugin: jQuery asmselect plugin.

This widget is way more useful as a select multiple (the default mode).

Resources

Documentation

Requirements
  • Yii 1.0 or above
    Installation
  • Extract the release file under protected/extensions
    Notes on updating
  • See the updated Examples below and the EAsmSelectEx: Class Documentation
    Usage

    See the following code examples.

with optgroups
$arrOptGroups = array(
            'Group1'=>array('value1'=>'The Option text.','value2'=>'option 2'),
            'Group2'=>array('value3'=>'option 3','value4'=>'option 4')
        	);

$arrSelected = array('value1', 'value3');

try
{
	$this->widget('application.extensions.asmselectex.EAsmSelectEx',
		array(
			'name' => 'asmSelect1',
			'data' => $arrOptGroups,
			'selected' => $arrSelected,
			'htmlOptions' => array('title'=>"Select a Item."),
			'scriptOptions' => array('addItemTarget'=>'bottom',
									 'animate'=>true,
									 'highlight'=>true,
									 'sortable'=>false)
		)
	);
} 
catch (Exception $e) 
{
    echo 'Caught Exception: ' .  $e->getMessage() . "<br />\n";
}	

Use the above example to create a select-mutliple with optgroups.

without optgroups
$arrOptions = array('value1'=>'The Option text.','value2'=>'option 2','value3'=>'option 3');

try
{
	$this->widget('application.extensions.asmselectex.EAsmSelectEx',
		array(
			'name' => 'asmSelect2',
			'data' => $arrOptions,
			'selected' => array('value1', 'value3'),
			'htmlOptions' => array('title'=>"Select a Item."),
			'scriptOptions' => array('addItemTarget'=>'bottom',
									 'animate'=>true,
									 'highlight'=>true,
									 'sortable'=>false)
		)
	); 
} 
catch (Exception $e) 
{
    echo 'Caught Exception: ' .  $e->getMessage() . "<br />\n";
}	

Use the above example to create a select-mutliple without optgroups.

As an CHtml::activeDropDownList from a CModel
$users = User::model()->findAll(array('select'=>array('id', 'username', 'group')));

foreach($users as $user)
	$UserList[$user->group][$user->id]=$user->username;

try
{	
	$this->widget('application.extensions.asmselectex.EAsmSelectEx',
		array(
			'model' => User::model(),
			'attribute' => "id",
			'data' => $UserList,
			'htmlOptions' => array('title'=>"Select a User."),
			'scriptOptions' => array('sortable'=>true)
		)
	); 
} 
catch (Exception $e) 
{
    echo 'Caught Exception: ',  $e->getMessage(), "<br />\n";
}	

Use the above example to create a "active" Widget, from a Model, based on CHtml::activeDropDownList,
in this case the $selected property isn´t used anymore, use the $attribute property of
CHtml::activeDropDownList instead.

customizing
$arrOptions = array('value1'=>'1. Item.','value2'=>'2. Item','value3'=>'3. Item');

try
{
	$myAsmSelect = $this->createWidget('application.extensions.asmselectex.EAsmSelectEx',
		array(
			'name' => 'asmSelect3',
			'data' => $arrOptions,
			'selected' => array('value1', 'value3'),
			'htmlOptions' => array('title'=>"Select a Item."),
			'scriptOptions' => array('sortable'=>true),
			'cssFile'=>'myCSSFile.css'
		)
	);
	
	$myAsmSelect->htmlOptions = array('title'=>"Select a Item to assign.");
	
	$myAsmSelect->applyScriptOption('removeLabel', 'revoke');
	$myAsmSelect->applyScriptOption('highlightAddedLabel', 'assigned: ');
	$myAsmSelect->applyScriptOption('highlightRemovedLabel', 'revoked: ');
	$myAsmSelect->applyScriptOption('highlight', true);
	
	$myAsmSelect->run(); 
} 
catch (Exception $e) 
{
    echo 'Caught Exception: ' .  $e->getMessage() . "<br />\n";
}

Use the above example to create an instance of EAsmSelectEx.

By setting the cssFile property, you can easily theme the widget´s instances.
Just make a copy of the original asmselect.css and make the
classes fit your needs or use for example:
applyScriptOption('listClass', 'myClassName').
jQuery asmselect: Modifiable CSS Classes

Class Documentation

EAsmSelectEx: Class Documentation

Change Log

February 4, 2009
  • v 1.3
    • updated the scriptfiles shipped with the widget
    • new class design, now derivers from CInputWidget.
    • see documentation!
January 16, 2009
  • v 1.2
    • new class design, see documentation!
January 11, 2009
  • v 1.1
    • added type checks+exceptions for all params,
    • added required check for the name-param,
    • now using registerScript($name,$script,POS_READY) instead of a quick and dirty code
January 10, 2009
  • Initial release.
7 1
3 followers
824 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Tags:
Developed by: ironic
Created on: Jan 10, 2009
Last updated: 15 years ago

Downloads

show all