PHP code example of gitrequests / yii2-widget-easyautocomplete

1. Go to this page and download the library: Download gitrequests/yii2-widget-easyautocomplete library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gitrequests / yii2-widget-easyautocomplete example snippets


echo EasyAutocomplete::widget([
    'pluginOptions' => [
        'url' => Url::to('data/countries.json'),
        'getValue' => 'name'
    ]
]);

echo $form->field($model, 'address')->widget(EasyAutocomplete::className(), [
    'pluginOptions' => [
        'url' => Url::to('data/countries.json'),
        'getValue' => 'name'
    ]
]);

echo $form->field($model, 'address')->widget(EasyAutocomplete::className(), [
    'pluginOptions' => [
        'url' => Url::to('data/countries.json'),
        'getValue' => 'name'
        'list' => [
            'maxNumberOfElements' => 10,
            'match' => [
                'enabled' => true,
                'method' => new JsExpression(<<<JavaScript
                    function(element, phrase) {

                        var searches = phrase.split(' ')
                        var count = 0;

                        for (var search of searches) {
                            if (element.search(search) > -1) {
                                count++;
                            }
                        }

                        return searches.length === count
                    }
                JavaScript
                )
            ]
        ]
    ]
]);

$ php composer.phar