Autocomplete With Cjuiautocomplete

im trying to make an autocomplete filde that need to have a key=>value

like p_id=>p_name

and it not work at all!

i have try hours to do it witeout success :(

please help me…

view:


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

    'name'=>'thelist',

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

    $.ajax({

        url: "'.$this->createUrl('main/dynamicDropBox').'",

        type: "post",

        data: {

            

           tableTyp: $("#tableTyp").val(),

        },

        success: function (data) {

                response(data);

        }

    })

 }',

     'id'=>'thelist',

    // additional javascript options for the autocomplete plugin

    'options'=>array(

        

        'minLength'=>'2',

    ),

    'htmlOptions'=>array(

        'style'=>'height:20px;',

    ),

));

and at controller


      

$list= Worker::model()->getAllWorkerList();

              

              foreach ($list as $value) 

      {

        $arr[] = array(

          'label'=>$value->worker_nickname,  // label for dropdown list

          'value'=>$value->worker_nickname,  // value for input field

          'id'=>$value->worker_code,            // return value from autocomplete

        );

      }

      echo CJSON::encode($arr);

Hi,

No its wrong… you should use chtml::listdata() then you will get array with id and name… Just search for some example using chtml listdata() method.

Best of luck