avikarsha / yii2-tagsinput
yii2-tagsinput 是 [bootstrap-tagsinput](https://github.com/timschlechter/bootstrap-tagsinput) 的 Yii 2 封装,结合 [typeahead.js](https://twitter.github.io/typeahead.js/)
1.0.2
2016-06-22 09:11 UTC
Requires
- bower-asset/bootstrap-tagsinput: ~0.8
- bower-asset/typeahead.js: 0.10.* | ~0.11.0
- yiisoft/yii2: ~2.0
- yiisoft/yii2-bootstrap: ~2.0.0
Requires (Dev)
- phpunit/phpunit: ~5.0
This package is not auto-updated.
Last update: 2024-09-26 01:25:27 UTC
README
安装
通过 Composer
$ composer require avikarsha/yii2-tagsinput
或者在 composer.json
文件的 require 部分添加:
"avikarsha/yii2-tagsinput": "*"
to the require section of your composer.json
file.
使用方法
在视图文件中。
<?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/