Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

<td width="23%" class="table_data_align"> <?

php $this->widget('CAutoComplete', array( //name of the html field that will be generated 'name'=>'se archterm', //replace controller/action with real ids 'url'=>arra y('site/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'= >2, 'delay'=>10 0, //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 'htmlOption s'=>array('size'=>'30'), 'methodChai n'=>".result(function(event,item){\$(\"#wordId\").val(item[1]);})", )); ?> <?php echo CHtml::hi ddenField('wordId'); ?> </td>

public function actionAutoCompleteLookup() { 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 CAutoComplet e widget $limit = min($_GET['limit'], 50); /*$criteria = new CDbCriteria; $criteria->condition = "word LIKE :sterm"; $criteria->params = array(":sterm"=>"%$name%"); $criteria->limit = $limit; $wordArray = Dictionary::model()->findAll($criteria);*/ $con=Yii::app()->db;

$wordArray=$con->createCommand("select * from dictionary")->queryAll() ; $returnVal = ''; foreach($wordArray as $a) { $returnVal .= $a['word'].' '.$a['wordId']."\n"; } echo $returnVal; } } http://www.yiiframework.com/wiki/47/ http://www.larryullman.com/2010/01/04/simple-authentication-with-the-yii-framewo rk/ http://www.yiiframework.fr/documentation/53-autentification-et-autorisation.html http://www.larryullman.com/2010/01/07/custom-authentication-using-the-yii-framew ork/

You might also like