Yii Framework Forum: CAutocomplete - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CAutocomplete Rate Topic: -----

#1 User is offline   Zahid Mughal 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 21-April 10
  • Location:Pakistan

Posted 20 May 2010 - 12:16 AM

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


//replace controller/action with real ids
'max'=>10, //specifies the max number of items to display

//specifies the number of chars that must be entered
//before autocomplete initiates a lookup
'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,),

//echo CHtml::textField('referer_patient_id');
<?php echo CHtml::textField('referer_patient_id'); ?>

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;
// $userArray = User::model()->findAll($criteria);
$returnVal = '';
foreach($userArray as $userAccount)
$returnVal .= $userAccount->getAttribute('first_name').'|'.$userAccount->getAttribute('id')."\n";

echo $returnVal;
Zahid Mughal


#2 User is offline   PoL 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 506
  • Joined: 05-November 08
  • Location:Buenos Aires, Argentina

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...
Don't say what you think, think what you say
The problem is communication! Excess of communication!

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users