Select2 -- selected value does not update database

Good morning all,

So I am trying to use select2 querying the database because there are 30000 records this is really the only efficient way I could think of.

My problem is if I just submit this form the pole_id doesn’t update.

Can someone help either with jquery getting the id or telling me why the select box doesn’t update the pole_id field in the db?

<?php
/* @var $this JpapolesController */
/* @var $model Jpapoles */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'jpapoles-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'pole_id'); ?>
		<?php echo $form->textField($model,'pole_id',array('id'=>'pole_id')); ?>
		
		<?php 
		$list = CHtml::listData(Poles::model()->findAll(array('order' => 'pole_number')), 'id', 'pole_number');
        //echo $form->dropDownList($model, 'pole_id', $list, array('class'=>"js-example-basic-multiple", 'name'=>'pole_id', 'multiple'=>'multiple'));
        //
		echo CHtml::hiddenField('selectbox_pole_id', '', array('class' => 'span5'));

        $this->widget('ext.select2.ESelect2',array(
            'id'=>'myselect',
            'selector' => '#selectbox_pole_id',
            'options'  => array(
            'allowClear'=>true,
            'placeholder'=>'Selecione a Pole',
           'minimumInputLength' => 3, 
             
           'ajax' => array(
            'url' => Yii::app()->createUrl('jpapoles/poles'),
             'type'=>'GET',
            'dataType' => 'json',
            'quietMillis'=> 100,
            'data' => 'js: function(text,page) {
            return {
                        q: text, 
                        page_limit: 10,
                        page: page,
                    };

                }',

            'results'=>'js:function(data,page) { var more = (page * 10) < data.total; return {results: data, more:more }; js:$("#Jpapoles_pole_id").attr("value",data.id);

        	}

            ',
	          ),

	       ),

        ));


		?>
		<?php echo $form->error($model,'pole_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'member_id'); ?>
		<?php //echo $form->textField($model,'member_id'); ?>
		<?php 
		$list = CHtml::listData(Members::model()->findAll(array('order' => 'abriviation')), 'id', 'abriviation');
        echo $form->dropDownList($model, 'member_id', $list);
		?>
		<?php echo $form->error($model,'member_id'); ?>
	</div>

	<div class="row">
		<?php //echo $form->labelEx($model,'jpa_id'); ?>
		<?php echo $form->hiddenField($model,'jpa_id', array('value'=>$_GET['jpano'])); ?>
		<?php echo $form->error($model,'jpa_id'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->
<script type="javascript">

$("#myselect").on("change", function (e) { 
    var id = $("#myselect").select2("data")[0].id;

   // Now you can work with the selected value, i.e.:
   $("#pole_id").val(id);
   alert(id);
});



</script>