acSelect (autocomplete Select) uses the CAutocomplete class to have a quick selection of entries and displays some selected data of the selected entry.
Resources ¶
Documentation ¶
Requirements ¶
- Yii 1.0 or above
- Sessions
- Jquery
Installation ¶
- Extract the release file under
protected/extensions
- added a modificated newer version of jquery_autocomplete.js cause some focus() problems in IE on hidden search fields created js errors.
Usage ¶
See the following code example:
<div class="simple">
<?php
echo CHtml::activeLabel($userlist,'AddressID');
/*
* which fields should be displayed in the info part
* label => columns of model to display
*/
$info_fields=array(
'Name'=>array('FirstName','LastName'),
'EMail'=>array('EMail'),
'Country'=>array('Country'),
);
/*
* glue for multiple columns if no glue value is given <br /> is used
*/
$info_glues=array(
'Name'=>' ',
);
/* js list pattern for the drop down list */
$list_pattern="'<small>'+i + '/' + max + ':</small> <b>' + row.lastname +' '+row.firstname+ '</b><br /><small>'+ row.email+ ' '+ row.country+ '</small>'";
/*
* set colModel (columns to select for display and return)
* tablecolumn => options
* 0 - display name ( not used yet maybe for generated js info pattern etc.
* 1 - datafield
* 2 - searchpattern eg. name: country:
* 3 - searchable (2 -> yes and default, 1 -> yes, 0 -> no.)
*/
$colModel=array();
$colModel['ID'] = array('ID','id','id',1); // searchable
$colModel['LastName'] = array('LastName','lastname','lastname',2); // searchable and default
$colModel['FirstName'] = array('FirstName','firstname','firstname',1); // searchable
$colModel['EMail'] = array('EMail','email','email',1); // searchable
$colModel['Country'] = array('Country','country','country',1); // searchable
$ac_select_options=array(
'model' =>$userlist, // your model object of the admin form
'select_model'=> addresslist::model(), // model class of the selection
'attribute' => "AddressID", // which attribute
'actionPrefix'=>'pro.', // has to be the same as in the controller
'name'=>'AddressID', // name
'colmodel'=>$colModel,
'buttonLabel'=>'User', // label of the change button 'change ...'
'default_search_data_field'=>'lastname', // default data field for setting in the search field
'default_data_field'=>'id', // default data field for setting the value of the hidden field on selection
'info_fields'=>$info_fields,
'info_glues'=>$info_glues,
'list_pattern'=>$list_pattern,
);
$ACSelectobj=$this->createWidget('application.extensions.acselect.ACSelect',$ac_select_options);
$ACSelectobj->run();
?>
</div>
and in the controller
public function actions()
{
return array(
'pro.'=>'application.extensions.acselect.ACSelect',
)
}
'pro.' < could be changed but must be also set in the widget call.
don't forget to set the access rules permission in your controller e.g. public function accessRules() {
return array(
array('allow', // allow all users to perform 'fillacselect'
'actions'=>array('pro.fillacselect'), //
'users'=>array('*')
),
array('deny', // deny any other actions for users
'users'=>array('*'),
),
); }
fillacselect is the action name to fill the widget. Only needed if you have array('deny', // deny any other actions for users
'users'=>array('*'),
),
in your accessrules.
Change Log ¶
August 27, 2009 ¶
- doku addition acessrules
April 3, 2009 ¶
- Initial release.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.