Go to file
Garion Herman 2620218fe4 Merge branch '2.2' into 2.3 2020-02-13 15:28:42 +13:00
_config FIX Make config namespace more specific 2018-12-19 21:55:03 +13:00
client Merge branch '2.2' 2019-02-19 11:21:23 +07:00
docs/en DOCS Update StringTagField example code to explain the input source options 2018-11-15 23:15:30 +02:00
src Merge branch '2.1' into 2.2 2020-02-13 15:18:32 +13:00
templates/SilverStripe/TagField Additional changes to convert tagfield to use react-select 2018-07-16 13:27:11 +12:00
tests Add tests for schema generation, further switch to short array syntax 2018-11-16 11:29:49 +02:00
.editorconfig NEW Converting tagfield to use react components 2018-07-11 17:47:38 +12:00
.eslintrc.js Additional changes to convert tagfield to use react-select 2018-07-16 13:27:11 +12:00
.gitattributes Added standard git attributes 2015-11-19 19:13:48 +13:00
.gitignore FIX Adding a debounce to fetching lazy loaded tags with tag field 2018-12-04 16:15:47 +13:00
.scrutinizer.yml FIX Update module for latest SS4, vendorise 2017-10-18 14:19:15 +13:00
.travis.yml Require source and specify admin version in Travis config 2018-08-18 10:12:51 +12:00
.upgrade.yml FIX SS4 compatibility updates, PSR-4 in tests, table_name in stubs 2017-06-22 17:15:17 +12:00
_config.php FIX Update module for latest SS4, vendorise 2017-10-18 14:19:15 +13:00
code-of-conduct.md Added standard code of conduct 2015-11-21 20:17:21 +13:00
codecov.yml FIX Update module for latest SS4, vendorise 2017-10-18 14:19:15 +13:00
composer.json Remove obsolete branch alias 2019-04-15 15:49:57 +12:00
contributing.md Made supported 2015-09-09 13:28:43 +12:00
license.md Updated license year 2016-01-01 06:38:06 +13:00
package.json Merge branch '2.2' 2019-02-19 11:21:23 +07:00
phpcs.xml.dist Add individual phpcs ruleset to Travis builds 2018-08-18 10:09:56 +12:00
phpunit.xml.dist FIX Update module for latest SS4, vendorise 2017-10-18 14:19:15 +13:00
readme.md Update readme.md 2019-02-13 12:22:45 +00:00
webpack.config.js NEW Converting tagfield to use react components 2018-07-11 17:47:38 +12:00
yarn.lock Merge branch '2.2' 2019-02-19 11:21:23 +07:00

readme.md

Tag Field

Custom tag input field, for SilverStripe.

Build Status Code Quality Code coverage Version License SilverStripe supported module

Requirements

  • SilverStripe 4.0

Installing

$ composer require silverstripe/tagfield

Using

Relational Tags

use SilverStripe\ORM\DataObject;

class BlogPost extends DataObject
{
	private static $many_many = [
		'BlogTags' => BlogTag::class
	];
}
use SilverStripe\ORM\DataObject;

class BlogTag extends DataObject
{
	private static $db = [
		'Title' => 'Varchar(200)',
	];

	private static $belongs_many_many = [
		'BlogPosts' => BlogPost::class
	];
}
$field = TagField::create(
	'BlogTags',
	'Blog Tags',
	BlogTag::get(),
	$this->BlogTags()
)
	->setShouldLazyLoad(true) // tags should be lazy loaded
	->setCanCreate(true);     // new tag DataObjects can be created

Note: This assumes you have imported the namespaces class, e.g. use SilverStripe\TagField\TagField;

String Tags

use SilverStripe\ORM\DataObject;

class BlogPost extends DataObject
{
	private static $db = [
		'Tags' => 'Text',
	];
}
$field = StringTagField::create(
	'Tags',
	'Tags',
    ['one', 'two'],
	explode(',', $this->Tags)
);

$field->setShouldLazyLoad(true); // tags should be lazy loaded

You can find more in-depth documentation in docs/en.

Versioning

This library follows Semver. According to Semver, you will be able to upgrade to any minor or patch version of this library without any breaking changes to the public API. Semver also requires that we clearly define the public API for this library.

All methods, with public visibility, are part of the public API. All other methods are not part of the public API. Where possible, we'll try to keep protected methods backwards-compatible in minor/patch versions, but if you're overriding methods then please test your work before upgrading.

Reporting Issues

Please create an issue for any bugs you've found, or features you're missing.