https://github.com/muhiddingithub/yii2-autocomplete
yii2-autocomplete jquery ui
https://github.com/muhiddingithub/yii2-autocomplete
autocomplete jquery-autcomplete yii2 yii2-autocomplete yii2-extension
Last synced: 6 months ago
JSON representation
yii2-autocomplete jquery ui
- Host: GitHub
- URL: https://github.com/muhiddingithub/yii2-autocomplete
- Owner: muhiddingithub
- License: mit
- Created: 2017-10-25T07:33:08.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-26T06:42:29.000Z (almost 9 years ago)
- Last Synced: 2025-10-10T11:39:18.057Z (10 months ago)
- Topics: autocomplete, jquery-autcomplete, yii2, yii2-autocomplete, yii2-extension
- Language: JavaScript
- Size: 16.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yii2-autocomplete
yii2-autocomplete jquery ui
Installation
------------
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require muhiddingithub/yii2-autocomplete "dev-master"
```
or add
```
"muhiddingithub/yii2-autocomplete": "dev-master"
```
to the require section of your `composer.json` file.
[Jquery source](https://jqueryui.com/autocomplete/)
Usage
-----
```php
echo \muhiddin\autocomplete\AutoComplete::widget([
'id' => 'search',
'form'=>$form, // ActiveForm widget object
'model'=>$model, // model
'attribute'=>'model_attribute', // attribute of model
'value' => '',
'name' => 'name',
'options' => [
'class' => 'form-control form-group-margin',
'dir' => "ltr",
'placeholder' => "search",
],
'pluginOptions' => [
'minChars' => 3,
'serviceUrl' => \yii\helpers\Url::toRoute(['custom-controlller/customer-action']),
'width' => '40%',
'onSelect' => 'function(suggestion){
// call onselect found element function
}'
]
])
```
in custom-controlller/customer-action
-----
```
$query = Yii::$app->request->get('query');
if (!empty($query)) {
$find = MyModel::find()->andFilterWhere(['like','column_name',$query]);
$allModels = $find->column();
echo json_encode([
'suggestions' => $allModels
]);
} else {
echo json_encode(['status' => 'failure']);
}
```