Dear Master of Yii,

My name is Chinmi, iam beginner in Yii.

i use widget zii.widgets.jui.CJuiAutoComplete to get nama and quantity from tbl_buku database.

and then also i want to automaticaly change another textfield quantity when i choose selected data nama from jcuiautocomplete.

here is program

//my controller BukuController.php

public function actionJudulbukulist(){

$sql = 'SELECT nama, quantity FROM tbl_buku WHERE nama LIKE :nbk';

$command = Yii::app()->db->createCommand($sql);

$command->bindValue(":nbk", '%'.$_GET['term'].'%', PDO::PARAM_STR);

$rows = $command->queryAll();            

echo CJSON::encode($rows);



my view

<div class="">


            &#036;this-&gt;widget('zii.widgets.jui.CJuiAutoComplete', array(






                'options'=&gt; array(



                    'select'=&gt;&quot;js:function(event, ui) {








                    'size'=&gt; 100,






// have id= "Buku_quantity"

<div class=""><?php echo $form->textField($model,‘quantity’,array(‘size’=>4,‘maxlength’=>4));?></div>

i need help, why when i enter 2 letter pop up on the buttom cjuiautocomplete field only blank.

i try to see JSON from judulBukulist() function it return

[{"nama":"Buku Test","quantity":"280"},{"nama":"KURA - KURA","quantity":"950"}]

and then i try to remove quantity from sql syntac

$sql = ‘SELECT quantity FROM tbl_buku WHERE nama LIKE :nbk’;

return data

[{"nama":"KURA - KURA"},{"nama":"Buku Test"}]

it still not working it is the same when i enter 2 letter will popup blank

and then i try to change $rows = $command->queryAll(); with $rows = $command->queryColumn();

its return data

["KURA - KURA","Buku Test"]

it working when i enter 2 letrer pop up will show up

but it will not provide quantity data which i will use for change another texfield "Buku_quantity" id.

Please help me master…

thank you for your advice Master of Yii.



[SOLVED] this is the solution…

i finnaly find the solution.

cJuiAutocomplete only accept several format like array, or array object and function.

here is my all program…

//my controller BukuController.php

public function actionJudulbukulist()




        &#036;sql = 'SELECT nama,quantity FROM tbl_buku WHERE nama LIKE :nbk';

        &#036;command = Yii::app()-&gt;db-&gt;createCommand(&#036;sql);

        &#036;command-&gt;bindValue(&quot;:nbk&quot;, '%'.&#036;_GET['term'].'%', PDO::PARAM_STR);

	//&#036;rows = &#036;command-&gt;queryColumn();

            &#036;rows = &#036;command-&gt;queryAll();

            &#036;result = array();

            foreach(&#036;rows as &#036;row){

                &#036;result[] = array(

                  'label'=&gt; &#036;row['nama'],


                  'quantity'=&gt; &#036;row['quantity'],



            echo CJSON::encode(&#036;result);



//my view

<div class="">


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



‘options’=> array(



‘select’=>"js:function(event, ui) {





‘size’=> 100,






// have id= "Buku_quantity"

<div class=""><?php echo $form->textField($model,‘quantity’,array(‘size’=>4,‘maxlength’=>4));?></div>


the controller result will be like

[{"label":"KURA - KURA","value":"KURA - KURA","quantity":"950"},{"label":"Buku Test","value":"Buku Test","quantity":"280"}]

this format JSON will be accepted by cJuiAutocomplete.

there are a label and value defined.

and key quantity is use for change another text field which have id ="Buku_quantity"

i hope this will be usefull for anyone who read this and have a problem like me…