【yii框架】Yii用AutoComplete实现表单自动提示

更新时间:2019-08-12    来源:php常用代码    手机版     字体:

【www.bbyears.com--php常用代码】

基本用法如下:

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;"
 ),
));
?>

本文来源:http://www.bbyears.com/jiaocheng/61677.html