skeeks / yii2-tagsinput
yii2-tagsinput 是一个用于 [bootstrap-tagsinput](https://github.com/timschlechter/bootstrap-tagsinput) 和 [typeahead.js](https://twitter.github.io/typeahead.js/) 的 Yii 2 包装器
1.1.0
2016-11-23 14:48 UTC
Requires
- bower-asset/bootstrap-tagsinput: *
- bower-asset/typeahead.js: 0.10.* | ~0.11.0
- yiisoft/yii2: *
- yiisoft/yii2-bootstrap: *
Requires (Dev)
- phpunit/phpunit: ~5.0
README
安装
通过 Composer
$ composer require avikarsha/yii2-tagsinput
或者添加
"avikarsha/yii2-tagsinput": "*"
到你的 composer.json
文件的 require 部分中。
用法
在你的视图文件中。
<?php use avikarsha\tagsinput\TagsinputWidget; ?> <?= $form->field($model, 'tags')->widget(TagsinputWidget::classname(), [ 'clientOptions' => [ 'trimValue' => true, 'allowDuplicates' => false ] ]) ?> <?php echo $form->field($model, 'places')->widget(TagsinputWidget::classname(), [ 'clientOptions' => [ "itemValue" => 'name', "itemText" => 'name', ], 'dataset' => [ [ 'remote' => [ 'url' => Url::to(['get-countries']). '?q=%QUERY', 'wildcard' => '%QUERY' ], 'datumTokenizer' => "Bloodhound.tokenizers.obj.whitespace('name')", 'displayKey' => 'name', 'limit' => 10, 'templates' => [ 'header' => '<h3 class="name">Country</h3>' ] ], [ 'remote' => [ 'url' => Url::to(['get-cities']). '?q=%QUERY', 'wildcard' => '%QUERY' ], 'datumTokenizer' => "Bloodhound.tokenizers.obj.whitespace('name')", 'displayKey' => 'name', 'limit' => 10, 'templates' => [ 'header' => '<h3 class="name">City</h3>' ] ], [ 'remote' => [ 'url' => Url::to(['get-states']). '?q=%QUERY', 'wildcard' => '%QUERY' ], 'datumTokenizer' => "Bloodhound.tokenizers.obj.whitespace('name')", 'displayKey' => 'name', 'limit' => 10, 'templates' => [ 'header' => '<h3 class="name">State</h3>' ] ] ] ]) ?>
更多选项,请访问: http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/