title: Yii 1.1.17 Select2 -- selected value does not update database
body: <p>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.</p>
  
  <p>My problem is if I just submit this form the pole_id doesn't update.</p>
  
  <p>Can someone help either with jQuery getting the id or telling me why the select box doesn't update the <code>pole_id</code> field in the db?</p>
  
  <pre><code>&lt;?php
  /* @var $this JpapolesController */
  /* @var $model Jpapoles */
  /* @var $form CActiveForm */
  ?&gt;
  
  &lt;div class="form"&gt;
  
  &lt;?php $form=$this-&gt;beginWidget('CActiveForm', array(
      'id'=&gt;'jpapoles-form',
      'enableAjaxValidation'=&gt;false,
  )); ?&gt;
  
      &lt;p class="note"&gt;Fields with &lt;span class="required"&gt;*&lt;/span&gt; are required.&lt;/p&gt;
  
      &lt;?php echo $form-&gt;errorSummary($model); ?&gt;
  
      &lt;div class="row"&gt;
          &lt;?php echo $form-&gt;labelEx($model,'pole_id'); ?&gt;
          &lt;?php //echo $form-&gt;textField($model,'pole_id',array('id'=&gt;'pole_id')); ?&gt;
  
          &lt;?php 
          $list = CHtml::listData(Poles::model()-&gt;findAll(array('order' =&gt; 'pole_number')), 'id', 'pole_number');
          //echo $form-&gt;dropDownList($model, 'pole_id', $list, array('class'=&gt;"js-example-basic-multiple", 'name'=&gt;'pole_id', 'multiple'=&gt;'multiple'));
          //
          echo CHtml::hiddenField('selectbox_pole_id', '', array('class' =&gt; 'span5'));
  
          $this-&gt;widget('ext.select2.ESelect2',array(
              'id'=&gt;'myselect',
  
              'selector' =&gt; '#selectbox_pole_id',
              'options'  =&gt; array(
                  'allowClear'=&gt;true,
                  'placeholder'=&gt;'Select a Pole',
                  'minimumInputLength' =&gt; 3, 
  
                     'ajax' =&gt; array(
                      'url' =&gt; Yii::app()-&gt;createUrl('jpapoles/poles'),
                       'type'=&gt;'GET',
                      'dataType' =&gt; 'json',
                      'quietMillis'=&gt; 100,
                      'data' =&gt; 'js: function(text,page) {
                      return {
                                  q: text, 
                                  page_limit: 10,
                                  page: page,
                              };
  
                          }',
  
                      'results'=&gt;'js:function(data,page) { var more = (page * 10) &lt; data.total; return {results: data, more:more }; 
  
                      }
  
                      ',
                        ),
  
                     ),
  
          ));
  
  
          ?&gt;
          &lt;?php echo $form-&gt;error($model,'pole_id'); ?&gt;
      &lt;/div&gt;
  
      &lt;div class="row"&gt;
          &lt;?php echo $form-&gt;labelEx($model,'member_id'); ?&gt;
          &lt;?php //echo $form-&gt;textField($model,'member_id'); ?&gt;
          &lt;?php 
          $list = CHtml::listData(Members::model()-&gt;findAll(array('order' =&gt; 'abriviation')), 'id', 'abriviation');
          echo $form-&gt;dropDownList($model, 'member_id', $list);
          ?&gt;
          &lt;?php echo $form-&gt;error($model,'member_id'); ?&gt;
      &lt;/div&gt;
  
      &lt;div class="row"&gt;
          &lt;?php //echo $form-&gt;labelEx($model,'jpa_id'); ?&gt;
          &lt;?php echo $form-&gt;hiddenField($model,'jpa_id', array('value'=&gt;$_GET['jpano'])); ?&gt;
          &lt;?php echo $form-&gt;error($model,'jpa_id'); ?&gt;
      &lt;/div&gt;
  
      &lt;div class="row buttons"&gt;
          &lt;?php echo CHtml::submitButton($model-&gt;isNewRecord ? 'Create' : 'Save'); ?&gt;
      &lt;/div&gt;
  
  &lt;?php $this-&gt;endWidget(); ?&gt;
  
  &lt;/div&gt;&lt;!-- form --&gt;
  &lt;script type="javascript"&gt;
  
  $("#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);
  });
  
  
  
  &lt;/script&gt;
  </code></pre>