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;' ), )); ?>
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, )); }
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 )!