How to display images in CJuiAutoComplete without extenstions

Comparing #3 with #4

Revision #4 was created by Asmaa Asmaa on Oct 9, 2014, 10:04:36 PM.

Adding resources

Content

I wanted to customize the CJuiAutoComplete, so that it displays a thumb image before the label like the one shown in the following image: ![autocomplete thumb](http://media-cache-ec0.pinimg.com/736x/e5/63/16/e563163b9de20b24c1d1a49306f0089d.jpg "Autocomplete with thumb Example ") For me I needed to display a color thumb "color_img" before the color name "color_desc_e". Here is what you can do:
 
I
Here is what you can do in a very simple way, in your model controller:
 

```php
// In the access rules function
[...]
$return_array = array();
foreach($data as $sub) {
       // Set all of your view variables in this array $return_array[] = array(         // This is the color name 'label'=>$sub['color_desc_e'], 'value'=>$sub['color_id'], 'id'=>$sub['color_id'],         // This is the line containing the full path to the thumb image
'img' => Yii::app()->request->baseUrl.Yii::app()->params["colorUploadUrl"].$sub['color_img']
);
[...]
```

In your view
file _In my case it was _form_:
[...]
```

Check the comments in
linside the code, that's it !
 
 
 
Sources: 
 
 
[Your text to link here...](http://qadrio.wordpress.com/2012/02/09/how-to-customize-appearance-of-cjuiautocomplete-in-yii/ "How to customize appearance of CJuiAutoComplete in Yii")
 
[Your text to link here...](http://www.yiiframework.com/wiki/217/custom-autocomplete-display-and-value-submission "http://www.yiiframework.com/wiki/217/custom-autocomplete-display-and-value-submission")