/** * Register script. * * @throws \yii\base\InvalidParamException */ protected function registerAssets() { $view = $this->context->getView(); MultipleInputAsset::register($view); $view = $this->context->getView(); $jsBefore = []; if (is_array($view->js) && array_key_exists(View::POS_READY, $view->js)) { foreach ($view->js[View::POS_READY] as $key => $js) { $jsBefore[$key] = $js; } } $template = $this->prepareTemplate(); $jsTemplates = []; if (is_array($view->js) && array_key_exists(View::POS_READY, $view->js)) { foreach ($view->js[View::POS_READY] as $key => $js) { if (array_key_exists($key, $jsBefore)) { continue; } $jsTemplates[$key] = $js; unset($view->js[View::POS_READY][$key]); } } $options = Json::encode(['id' => $this->id, 'template' => $template, 'jsTemplates' => $jsTemplates, 'max' => $this->max, 'min' => $this->min, 'attributes' => $this->prepareJsAttributes(), 'indexPlaceholder' => $this->getIndexPlaceholder()]); $js = "jQuery('#{$this->id}').multipleInput({$options});"; $view->registerJs($js); }