protected function initAutoComplete(&$options = [])
    {
        $autocomplete = ArrayHelper::getValue($options, 'autocomplete', []);

        // not Materialize autocomplete structure
        if (!is_array($autocomplete) || empty($autocomplete)) {
            return;
        }

        ArrayHelper::remove($options, 'autocomplete');

        $view = $this->form->getView();
        Html::addCssClass($options, ['autocomplete' => 'has-autocomplete']);

        MaterializePluginAsset::register($view);
        $autocompleteData['data'] = $autocomplete;

        $pluginOptions = Json::htmlEncode($autocompleteData);
        $js = "M.Autocomplete.init(document.querySelectorAll('.has-autocomplete', $pluginOptions))";

        $view->registerJs($js);
    }
protected function initAutoComplete(&$options = [])
    {
        $autocomplete = ArrayHelper::getValue($options, 'autocomplete', []);

        // not Materialize autocomplete structure
        if (!is_array($autocomplete) || empty($autocomplete)) {
            return;
        }

        ArrayHelper::remove($options, 'autocomplete');

        $view = $this->form->getView();
        Html::addCssClass($options, ['autocomplete' => 'has-autocomplete']);

        MaterializePluginAsset::register($view);
        $autocompleteData['data'] = $autocomplete;

        $pluginOptions = Json::htmlEncode($autocompleteData);
        $js = "M.Autocomplete.init(document.querySelectorAll('.has-autocomplete', $pluginOptions))";

        $view->registerJs($js);
    }
protected function initAutoComplete ( & $ options = [ ] ) { $ autocomplete = ArrayHelper :: getValue ( $ options , 'autocomplete' , [ ] ) ; // not Materialize autocomplete structure if ( ! is_array ( $ autocomplete ) || empty ( $ autocomplete ) ) { return ; } ArrayHelper :: remove ( $ options , 'autocomplete' ) ; $ view = $ this -> form -> getView ( ) ; Html :: addCssClass ( $ options , [ 'autocomplete' => 'has-autocomplete' ] ) ; MaterializePluginAsset :: register ( $ view ) ; $ autocompleteData [ 'data' ] = $ autocomplete ; $ pluginOptions = Json :: htmlEncode ( $ autocompleteData ) ; $ js = "M.Autocomplete.init(document.querySelectorAll('.has-autocomplete', $pluginOptions))" ; $ view -> registerJs ( $ js ) ; }
Initializes the Materialize autocomplete feature.

@param array $options the tag options as name-value-pairs.
To use the Materialize autocomplete feature, set the option key `autocomplete` to an array.
The array keys are the strings to be matched and the values are optional image URLs. If an image URL is provided,
a thumbnail is shown next to the string in the autocomplete suggestion list:

```php
...
'autocomplete' => [
'George' => 'http://lorempixel.com/40/40/people',
'Fiona' => null     // no thumbnail
],
...
```

To use the HTML5 autocomplete feature, set this option to `on`. To explicitely disable the HTML5 autocomplete, set
this option to `off`. Either `on` or `off` disables the Materialize autocomplete feature.

@see https://materializecss.com/autocomplete.html
Initializes the Materialize autocomplete feature .