Skip to content

Commit aadc2b8

Browse files
yii2 taginput with typeahead
0 parents  commit aadc2b8

11 files changed

+563
-0
lines changed

.gitattributes

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
# Ignore all test and documentation with "export-ignore".
5+
/.gitattributes export-ignore
6+
/.gitignore export-ignore
7+
/.travis.yml export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/.scrutinizer.yml export-ignore
10+
/tests export-ignore

.gitignore

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
build
2+
docs
3+
vendor
4+
5+
# cache directories
6+
Thumbs.db
7+
*.DS_Store
8+
*.empty
9+
10+
#phpstorm project files
11+
.idea
12+
13+
#netbeans project files
14+
nbproject
15+
16+
#eclipse, zend studio, aptana or other eclipse like project files
17+
.buildpath
18+
.project
19+
.settings
20+
21+
# composer itself is not needed
22+
composer.phar
23+
composer.lock
24+
25+
# mac deployment helpers
26+
switch
27+
index

.scrutinizer.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
filter:
2+
excluded_paths: [tests/*]
3+
checks:
4+
php:
5+
code_rating: true
6+
remove_extra_empty_lines: true
7+
remove_php_closing_tag: true
8+
remove_trailing_whitespace: true
9+
fix_use_statements:
10+
remove_unused: true
11+
preserve_multiple: false
12+
preserve_blanklines: true
13+
order_alphabetically: true
14+
fix_php_opening_tag: true
15+
fix_linefeed: true
16+
fix_line_ending: true
17+
fix_identation_4spaces: true
18+
fix_doc_comments: true
19+
tools:
20+
external_code_coverage:
21+
timeout: 600
22+
runs: 3
23+
php_analyzer: true
24+
php_code_coverage: false
25+
php_code_sniffer:
26+
config:
27+
standard: PSR2
28+
filter:
29+
paths: ['src']
30+
php_loc:
31+
enabled: true
32+
excluded_dirs: [vendor, tests]
33+
php_cpd:
34+
enabled: true
35+
excluded_dirs: [vendor, tests]

.travis.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
language: php
2+
3+
php:
4+
- 5.6
5+
- 7.0
6+
- hhvm
7+
8+
install:
9+
- composer self-update
10+
- composer global require "fxp/composer-asset-plugin:1.1.4"
11+
- composer install
12+
13+
before_script:
14+
- travis_retry composer self-update
15+
- travis_retry composer install --no-interaction --prefer-source --dev
16+
17+
script:
18+
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
19+
20+
after_script:
21+
- wget https://scrutinizer-ci.com/ocular.phar
22+
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover

README.md

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# yii2-tagsinput
2+
3+
## Install
4+
5+
Via Composer
6+
7+
```bash
8+
$ composer require avikarsha/yii2-tagsinput
9+
```
10+
11+
or add
12+
13+
```
14+
"avikarsha/yii2-tagsinput": "*"
15+
```
16+
17+
to the require section of your `composer.json` file.
18+
19+
20+
## Usage
21+
22+
On your view file.
23+
24+
```php
25+
26+
<?php
27+
use avikarsha\tagsinput\TagsinputWidget;
28+
?>
29+
30+
<?= $form->field($model, 'tags')->widget(TagsinputWidget::classname(), [
31+
'clientOptions' => [
32+
'trimValue' => true,
33+
'allowDuplicates' => false
34+
]
35+
]) ?>
36+
37+
<?php echo $form->field($model, 'places')->widget(TagsinputWidget::classname(), [
38+
'clientOptions' => [
39+
"itemValue" => 'name',
40+
"itemText" => 'name',
41+
],
42+
'dataset' => [
43+
[
44+
'remote' => [
45+
'url' => Url::to(['get-countries']). '?q=%QUERY',
46+
'wildcard' => '%QUERY'
47+
],
48+
'datumTokenizer' => "Bloodhound.tokenizers.obj.whitespace('name')",
49+
'displayKey' => 'name',
50+
'limit' => 10,
51+
'templates' => [
52+
'header' => '<h3 class="name">Country</h3>'
53+
]
54+
],
55+
[
56+
'remote' => [
57+
'url' => Url::to(['get-cities']). '?q=%QUERY',
58+
'wildcard' => '%QUERY'
59+
],
60+
'datumTokenizer' => "Bloodhound.tokenizers.obj.whitespace('name')",
61+
'displayKey' => 'name',
62+
'limit' => 10,
63+
'templates' => [
64+
'header' => '<h3 class="name">City</h3>'
65+
]
66+
],
67+
[
68+
'remote' => [
69+
'url' => Url::to(['get-states']). '?q=%QUERY',
70+
'wildcard' => '%QUERY'
71+
],
72+
'datumTokenizer' => "Bloodhound.tokenizers.obj.whitespace('name')",
73+
'displayKey' => 'name',
74+
'limit' => 10,
75+
'templates' => [
76+
'header' => '<h3 class="name">State</h3>'
77+
]
78+
]
79+
]
80+
]) ?>
81+
82+
```
83+
84+
For more options, visit: http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/

composer.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "avikarsha/yii2-tagsinput",
3+
"description": "The yii2-tagsinput is a Yii 2 wrapper for [bootstrap-tagsinput](https://github.com/timschlechter/bootstrap-tagsinput) with [typeahead.js](https://twitter.github.io/typeahead.js/)",
4+
"type": "yii2-extension",
5+
"keywords": [
6+
"avikarsha",
7+
"yii2",
8+
"extension",
9+
"yii2-tagsinput",
10+
"yii2 tags input typeahead bloodhood"
11+
],
12+
"homepage": "https://github.com/avikarsha/yii2-tagsinput",
13+
"license": "BSD-3-Clause",
14+
"authors": [
15+
{
16+
"name": "Avikarsha Saha",
17+
"email": "[email protected]",
18+
}
19+
],
20+
"require": {
21+
"yiisoft/yii2": "~2.0",
22+
"yiisoft/yii2-bootstrap": "~2.0.0",
23+
"bower-asset/typeahead.js": "0.10.* | ~0.11.0",
24+
"bower-asset/bootstrap-tagsinput": "~0.6"
25+
},
26+
"require-dev": {
27+
"phpunit/phpunit": "~5.0"
28+
},
29+
"autoload": {
30+
"psr-4": {
31+
"avikarsha\\tagsinput\\": "src"
32+
}
33+
}
34+
}

phpunit.xml.dist

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="tests/bootstrap.php"
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
verbose="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="false">
12+
<testsuites>
13+
<testsuite name="wbraganca Test Suite">
14+
<directory>tests</directory>
15+
</testsuite>
16+
</testsuites>
17+
<filter>
18+
<whitelist>
19+
<directory suffix=".php">src/</directory>
20+
</whitelist>
21+
</filter>
22+
<logging>
23+
<log type="tap" target="build/report.tap"/>
24+
<log type="junit" target="build/report.junit.xml"/>
25+
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
26+
<log type="coverage-text" target="build/coverage.txt"/>
27+
<log type="coverage-clover" target="build/logs/clover.xml"/>
28+
</logging>
29+
</phpunit>

src/TagsinputAsset.php

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
namespace avikarsha\tagsinput;
3+
4+
/**
5+
* Asset bundle for tagsinput Widget
6+
*
7+
*/
8+
class TagsinputAsset extends \yii\web\AssetBundle
9+
{
10+
public $sourcePath = '@bower/bootstrap-tagsinput/dist';
11+
12+
public $css = [
13+
'bootstrap-tagsinput.css',
14+
];
15+
16+
public $js = [
17+
'bootstrap-tagsinput.min.js',
18+
];
19+
20+
public $depends = [
21+
'yii\web\JqueryAsset',
22+
'yii\bootstrap\BootstrapPluginAsset',
23+
'wbraganca\tagsinput\TypeaheadAsset'
24+
];
25+
}

0 commit comments

Comments
 (0)