retrieve value in CAutoComplete in update mode


I have a doubt in CAutoComplete widget…

i hv a table "feespaid" with three fields



here enrollment id is foreign key which is retrieved from table "course" course table has



in my view i hv a CAutoComplete widget for enrollment_id which is used to show enrollment_no from course table.

  <?php $this->widget('CAutoComplete', array(


                    'name'=>CHtml::activeName($model, 'enrollment_id'),








                    )); ?>

                <?php echo $form->hiddenField($model,'enrollment_id',array('id'=>'enrollment_id')); ?>

in my controller

 public function actionAutoCompleteLookup()


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


            /* q is the default GET variable name that is used by

            / the autocomplete widget to pass in user input


          $name = $_GET['q'];

       // this was set with the "max" attribute of the CAutoComplete widget

          $limit = min($_GET['limit'], 50);

          $criteria = new CDbCriteria;

          $criteria->condition = "enrollment_no LIKE :sterm";

          $criteria->params = array(":sterm"=>"%$name%");

          $criteria->limit = $limit;

          $course = CourseEnrollment::model()->findAll($criteria);

          $returnVal = '';

          foreach($course as $courseRecord)


             $returnVal .= $courseRecord->getAttribute('enrollment_no').'|'



          echo $returnVal;



it works well in creation…

my problem is i dont know how retrieve the enrollment no in CAutoComplete widget in update mode…

please help me

try with something like:

  <?php $this->widget('CAutoComplete', array(


                    'name'=>CHtml::activeName($model, 'enrollment_id'),


This should work well in update

thanks… it works really well…

what is en

enrollment0?? where do you define it??