Пример #1
0
 public function init()
 {
     $this->pluginOptions = array_merge($this->defaultAjaxOptions(), (array) $this->pluginOptions);
     if ($this->url) {
         $this->pluginOptions['ajax']['url'] = $this->url;
     }
     $this->pluginOptions['minimumInputLength'] = $this->minLength;
     $this->pluginOptions['initSelection'] = $this->getInitSelectionJs();
     $this->pluginOptions['ajax']['data'] = new JsExpression('function(term,page) { return {term:term}; }');
     $this->pluginOptions['ajax']['results'] = new JsExpression('function(data,page) { return {results:data}; }');
     parent::init();
 }
Пример #2
0
 public function init()
 {
     if ($this->placeholder_from_label) {
         $placeholder = $this->model->getAttributeLabel($this->attribute);
     } else {
         $placeholder = $this->placeholder ?: __('Select a tags...');
     }
     $this->options = ['placeholder' => $placeholder];
     $attribute = $this->attribute;
     $this->attribute = $attribute . 'Str';
     $models = Tag::find()->{$attribute}()->all();
     $tags = [];
     foreach ($models as $model) {
         $tags[] = $model->name;
     }
     $this->pluginOptions = ['tags' => $tags, 'tokenSeparators' => [',', ';'], 'maximumInputLength' => 64, 'allowClear' => true];
     parent::init();
 }