PHP development framework Yii Framework tutorial (34) Zii component-AutoComplete example

黄舟
Release: 2023-03-05 09:22:02
Original
1882 people have browsed it

CJuiAutoComplete can automatically prompt the user to input text based on the first few characters entered by the user when typing. It encapsulates the JUI autocomplete plugin.

The basic usage is as follows

$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'name'=>'city',
'source'=>$data,
// additional javascript options for the autocomplete plugin
'options'=>array(
'minLength'=>'2',
),
'htmlOptions'=>array(
'style'=>'height:20px;'
),
));
?>
Copy after login

The automatically prompted data source is completed by configuring the source attribute. In actual application, it can be read from databases, files, etc. For simplicity, this example uses an array defined in SiteController.

public function actionIndex()
{
$data=array('Nanjing', 'Beijing', 'Perth',
'Chicago','Paris','Pengnai','Sydney');
$this->render('index', array(
'data' => $data,
));
}
Copy after login

PHP development framework Yii Framework tutorial (34) Zii component-AutoComplete example

The above is the content of the PHP development framework Yii Framework tutorial (34) Zii component-AutoComplete example. For more related content, please pay attention to the PHP Chinese website (www.php.cn )!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!