Multitagging autocomletion wrapper for CJuiAutoComplete.
CJuiAutoComplete
Yii Framework >= 1.1.2
Insert following code into view
$this->widget('path.to.multicomplete.MultiComplete', array( 'model'=>$model, 'attribute'=>'news_tags', 'splitter'=>',', //'source'=>array('ac1', 'ac2', 'ac3'), 'sourceUrl'=>'search.html', // additional javascript options for the autocomplete plugin 'options'=>array( 'minLength'=>'2', ), 'htmlOptions'=>array( 'size'=>'60' ), ));
if you want to use static source - you must use source Option, if you want to get tags dynamically you must specify sourceUrl option, and use the following code in controller:
public function actionSearch() { //completion variants echo '[ "ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme" ]'; }
public function actionSearch($term) { if(Yii::app()->request->isAjaxRequest && !empty($term)) { $variants = array(); $criteria = new CDbCriteria; $criteria->select='tag'; $criteria->addSearchCondition('tag',$term.'%',false); $tags = tagsModel::model()->findAll($criteria); if(!empty($tags)) { foreach($tags as $tag) { $variants[] = $tag->attributes['tag']; } } echo CJSON::encode($variants); } else throw new CHttpException(400,'Invalid request. Please do not repeat this request again.'); }
splitter(string) - tag splitter to parse tag input string

Total 4 comments
Hi thank u . I suggest to develop it related to Gridview filter , Then will be perfect ext .
1 minute implementation, simple usage, great extension. Thank you!
Thanks, that's what I needed!
Excellent idea. I'll give it a try... ;)
Leave a comment
Please login to leave your comment.