Cjuiautocomplete Not Working ! (Yii Framework 1.1.3)

Hi, I’m a newbie and for days now I tried to make CJuiAutocomplete work and I can’t see what’s wrong. I’m using yii framework 1.1.3

Here’s my controller




public function actionAutocomplete()

	{ $list=array();

		if ((Yii::app()->request->isAjaxRequest ) && isset($_GET['term'])){

		

			$list = Yii::app()->LDAP->listFullLDAP("'".$_GET['term']."'");

			foreach ($list as $item){

					$res[] = array(

							'id' => $item['sn'].' '.$item['gn'],

							'value' => $item['sn'].' '.$item['gn'],

							'label' => $item['sn'].' '.$item['gn'],

							'mail' => $item['ml'],

					);

				}

			echo CJSON::encode($res);

				

			Yii::app()->end();

		}

		

	}



My view




<div class="row right">  

	           <?php  echo $form->labelEx($model,'stagiaire'); ?>

			<?php  //echo $form->hiddenField($model,'stagiaire');

				$this->widget('zii.widgets.jui.CJuiAutoComplete', array(

				'model'=>$model,

				'attribute'=>'stagiaire',

				'name'=>'FormInscription[stagiaire]',

				/*'source'=>"js:function(request, response) {

			        $.getJSON('".$this->createUrl('FormInscription/autocomplete')."', {

			            term: extractLast(request.term)

			        }, response);

			    }",*/

				'source'=>$this->createUrl('FormInscription/autocomplete'),

				'htmlOptions'=>array('placeholder'=>'','autocomplete'=>'off'),

			    // additional javascript options for the autocomplete plugin

			    /*'options'=>array(

						'minLength' => 2,

						'autoFill'=>false,

			            'showAnim'=>'fold',

						'select' => 'js:function(event, ui){

										$("#FormInscription_stagiaire").val(ui.item.label);return false;}',

			    ),*/

			));?>

			<?php echo $form->error($model,'stagiaire'); ?>

		</div>



LDAP is a component I created to be able to connect with informations from OpenLDAP. I can easily view my informations in the view file




[{"id":"Bouwa Dzeakou Marcel","value":"Bouwa Dzeakou Marcel","label":"Bouwa Dzeakou Marcel","mail":"bomb@yahoo.fr "},{"id":"Bouwa Maka Olive","value":"Bouwa Maka Olive","label":"Bouwa Maka Olive","mail":"bomb@yahoo.fr "},{"id":"Bouwa Fonkoua Josephine","value":"Bouwa Fonkoua Josephine","label":"Bouwa Fonkoua Josephine","mail":"bomb@yahoo.fr "}]



When I put the array directly on the "source" property of the autocomplete, it shows, but when I pass through the controller nothing shows.

When I pass through the database, there’s no problem except that when I add javascript, nothing shows, even when add the “echo form hidden field”. As you can see I’ve commented out everything that concerns Javascript!

Please, I really, really, really need help. It’s urgent!

please highlight your code first it not readable

ok done!

put in code snippet.press <> button from Bold panel,so you will get it.

I found that the javascript of the option property is working when it’s for a database query but only when there’s no echo hidden field.

But autocomplete call with my LDAP function is still not working.

check if you receiving the data thru ajax request in console

EDIT:

also look at this wiki article might help you

http://www.yiiframework.com/wiki/162/a-simple-action-for-cjuiautocomplete/

Considering the first option, I’ve never and don’t know how to use the console and the for the second one, I’m not taking data from a database but from a LDAP directory so can’t use CDbCriteria().

Sorry for my late response, I wasn’t around.

Shouldn’t


'source'=>$this->createUrl('FormInscription/autocomplete'),

actually be


'sourceUrl'=>array('formInscription/autocomplete'),

?

Everything works fine, because when I search data from a database it works but when I try to take data from the LDAP directory nothing shows while, as I said earlier it shows perfectly when I call it directly in the view.

Please does anyone have an idea what could be wrong? I can asure you I tried everything. Even the CAction proposed to me earlier.

Ok I found that the problem was with my LDAP function, it couldn’t search dynamically data from the directory.

I’m now trying to use the LDAP extension of Yii but am encountering some problems. Please has any one here ever used it before? I have problems with searching data using a filter, there’s an error and I don’t know why. Please has anyone here used the ldaprecord extension before?

Since I couldn’t find help with the ldap extension, I had to go back to my function and I found out it worked perfectly, I just had to restart openldap. Thanks to all does who tried to help.

God bless! He loves you…