Yii Cjuiautocomplete Not Saving Into Textarea

Happy New Year all!

Sorry to be a thicko - im back to a Yii project, and I’ve got the auto / suggest working, e.g. I type "tea " and “Teacher” appears, but when I submit, it says the field is empty, and looking with FireBug the field value doesnt have “Teacher” in it…

Do I need a hidden field with a specific ID/Name?


    <div class="row">

		<?php echo $form->labelEx($model,'client_2_occupation'); ?> [Auto from DB]

		<?php //echo $form->textField($model,'client_2_occupation',array('class'=>'typeahead-occupation','size'=>60,'maxlength'=>128)); ?>

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

		  //'model'=>$model,

		  'id'=>'client_2_occupation',

		  'name'=>'client_2_occupation',

		  'value'=>"Type keyword in here...",

		  'source' => CController::createUrl('site/suggest'),

		  'options'=>array(

		    'delay'=>300,

			'minLength'=>2,

		  ),

          )); ?>

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

	</div>


	/**

	 * Enables suggestive form fields.

	 */

	public function actionSuggest()

    {

		if (Yii::app()->request->isAjaxRequest && isset($_GET['term'])&&($keyword=trim($_GET['term']))!=='')

		{

				$models=FormFields::model()->findAll(array(

						'condition'=>'value_int LIKE :keyword OR value_char LIKE :keyword',

						'order'=>'value_char',

						'limit'=>5,

						'params'=>array(':keyword'=>"$keyword%")

				));

				$suggest=array();

				foreach($models as $model) {

						$suggest[] = array(

								'label'=>$model->value_char,

								'value'=>$model->value_char

						);

				}

				echo CJSON::encode($suggest);

		}               

        }

Ok, so I;ve tweaked it, and now it;s working so far!


    <div class="row">

		<?php echo $form->labelEx($model,'client_1_occupation'); ?> [Auto from DB]

        <?php

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

          'name'=>'LeadsAnnuity[client_1_occupation]',

           'source' => CController::createUrl('site/suggest'),

           'value' => ($model->client_1_occupation->client_1_occupation) ? $model->client_1_occupation->client_1_occupation : $model->client_1_occupation,

           'options' => array(

             'showAnim' => 'fold',

             'select' => 'js:function(event, ui){ jQuery("#client_1_occupation").val(ui.item["id"]); }'

            ),

            'htmlOptions' => array(

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

            ),

        ));

        ?>

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

	</div>