CAutocomplete

halllo can any body tell me that how to submit value from the CAutocomplete when button is pressed…

My _form.php

<div class="row">

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

                     //name of the html field that will be generated


					 


        'name'=&gt;'first_name',


		'model'=&gt;&#036;model,


				


		 


                     //replace controller/action with real ids


         'url'=&gt;array('patient_choices/autoCompleteLookup'), 


         'max'=&gt;10, //specifies the max number of items to display





                     //specifies the number of chars that must be entered 


                     //before autocomplete initiates a lookup


         'minChars'=&gt;1, 


         'delay'=&gt;500, //number of milliseconds before lookup occurs


         'matchCase'=&gt;false, //match case when performing a lookup?





                     //any additional html attributes that go inside of 


                     //the input field can be defined here


         'htmlOptions'=&gt;array('validateonsubmit' =&gt; TRUE,), 





         'methodChain'=&gt;&quot;.result(function(event,item){&#092;&#036;(&#092;&quot;#referer_patient_id&#092;&quot;).val(item[1]);})&quot;,


         ));


		  //echo CHtml::textField('referer_patient_id');


?&gt;


 &lt;?php echo CHtml::textField('referer_patient_id'); ?&gt;

</div>

My actionAutoCompleteLookup method in Controller

public function actionAutoCompleteLookup()

{


	Yii::log('Auto Complete method call by : '.Yii::app()-&gt;user-&gt;id,'info','system.web.Patient_detailsController');	


	if(Yii::app()-&gt;request-&gt;isAjaxRequest &amp;&amp; isset(&#036;_GET['q']))


	{


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


		/ the autocomplete widget to pass in user input


		*/


      &#036;name = &#036;_GET['q']; 


     // this was set with the &quot;max&quot; attribute of the CAutoComplete widget


	  &#036;limit = min(&#036;_GET['limit'], 50); 


      &#036;criteria = new CDbCriteria;


      &#036;criteria-&gt;condition = &quot;first_name LIKE :sterm&quot;;


      &#036;criteria-&gt;params = array(&quot;:sterm&quot;=&gt;&quot;%&#036;name%&quot;);


      &#036;criteria-&gt;limit = &#036;limit;


	  //&#036;model=&#036;this-&gt;loadModel();


	  &#036;userArray=patient_details::model()-&gt;findAll(&#036;criteria);


     // &#036;userArray = User::model()-&gt;findAll(&#036;criteria);


      &#036;returnVal = '';


      foreach(&#036;userArray as &#036;userAccount)


      {


         &#036;returnVal .= &#036;userAccount-&gt;getAttribute('first_name').'|'.&#036;userAccount-&gt;getAttribute('id').&quot;&#092;n&quot;;


      }


	  


	  //&#036;returnVal=&#036;name;


      echo &#036;returnVal;


   }


}

Check this:

Using CAutoComplete to display one value and submit another

Atencion is for 1.0.x, so may be, for 1.1.x needs some changes.

BTW, this is a spanish forum, you should not post in english here… please use the appropiate post for each thing…