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'=>'first_name',
'model'=>$model,
//replace controller/action with real ids
'url'=>array('patient_choices/autoCompleteLookup'),
'max'=>10, //specifies the max number of items to display
//specifies the number of chars that must be entered
//before autocomplete initiates a lookup
'minChars'=>1,
'delay'=>500, //number of milliseconds before lookup occurs
'matchCase'=>false, //match case when performing a lookup?
//any additional html attributes that go inside of
//the input field can be defined here
'htmlOptions'=>array('validateonsubmit' => TRUE,),
'methodChain'=>".result(function(event,item){\$(\"#referer_patient_id\").val(item[1]);})",
));
//echo CHtml::textField('referer_patient_id');
?>
<?php echo CHtml::textField('referer_patient_id'); ?>
</div>
My actionAutoCompleteLookup method in Controller
public function actionAutoCompleteLookup()
{
Yii::log('Auto Complete method call by : '.Yii::app()->user->id,'info','system.web.Patient_detailsController');
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 = "first_name LIKE :sterm";
$criteria->params = array(":sterm"=>"%$name%");
$criteria->limit = $limit;
//$model=$this->loadModel();
$userArray=patient_details::model()->findAll($criteria);
// $userArray = User::model()->findAll($criteria);
$returnVal = '';
foreach($userArray as $userAccount)
{
$returnVal .= $userAccount->getAttribute('first_name').'|'.$userAccount->getAttribute('id')."\n";
}
//$returnVal=$name;
echo $returnVal;
}
}
Page 1 of 1
CAutocomplete
#2
Posted 20 May 2010 - 07:22 AM
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...
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...
Don't say what you think, think what you say
The problem is communication! Excess of communication!
The problem is communication! Excess of communication!
Share this topic:
Page 1 of 1

Help













