Home  >  Article  >  php教程  >  Yii -AutoComplete 表单自动提示实例

Yii -AutoComplete 表单自动提示实例

WBOY
WBOYOriginal
2016-06-08 17:23:331144browse

本文章来给各位同学介绍Yii -AutoComplete 表单自动提示实例,有需要了解的同学可进入参考。

<script>ec(2);</script>


CJuiAutoComplete 在用户输入时可以根据用户输入的前几个字符自动提示用户可以输入的文字。它封装了 JUI autocomplete插件。

基本用法如下:


controller层代码:

——————————————-

 代码如下 复制代码

class SiteController extends Controller

{

 public function actionIndex()

 {

 $data=array(‘Nanjing’, ‘Beijing’, ‘Perth’,

‘Chicago’,'Paris’,'Pengnai’,'Sydney’);

 $this->render(‘index’, array(

 ‘data’ => $data,

 ));

 }

}


view层代码:

——————————————————

 代码如下 复制代码

$this->widget(‘zii.widgets.jui.CJuiAutoComplete’, array(

‘name’=>’city’,

’source’=>$data,

‘options’=>array(

 ‘minLength’=>’1′,//设置文本框中有最少有几个字符的时候开始提示

 ),

 ‘htmlOptions’=>array(

 ’style’=>’height:20px;’

 ),

));

?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn