SilverStripe module for editing tags (both in the CMS and other forms)
JavaScript PHP CSS
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
client Building distribution files Jul 17, 2018
css Tag field to look similar to list field (#108) Feb 20, 2018
docs/en SilverStripe 4 compatibility (#87) Jan 13, 2017
js Tag field to look similar to list field (#108) Feb 20, 2018
src Adding tests & various feedback updates Jul 17, 2018
templates/SilverStripe/TagField Additional changes to convert tagfield to use react-select Jul 16, 2018
tests Revert modification of tests to keep B/C Jul 17, 2018
.editorconfig NEW Converting tagfield to use react components Jul 11, 2018
.eslintrc.js Additional changes to convert tagfield to use react-select Jul 16, 2018
.gitattributes Added standard git attributes Nov 19, 2015
.gitignore Updating to use injector & removing storybook Jul 17, 2018
.scrutinizer.yml FIX Update module for latest SS4, vendorise Oct 18, 2017
.travis.yml Require source and specify admin version in Travis config Aug 17, 2018
.upgrade.yml FIX SS4 compatibility updates, PSR-4 in tests, table_name in stubs Jun 22, 2017
_config.php FIX Update module for latest SS4, vendorise Oct 18, 2017
changelog.md Update changelog for 1.3.0 May 18, 2016
code-of-conduct.md Added standard code of conduct Nov 21, 2015
codecov.yml FIX Update module for latest SS4, vendorise Oct 18, 2017
composer.json Merge branch '2.2' Jul 26, 2018
contributing.md Made supported Sep 9, 2015
license.md Updated license year Dec 31, 2015
package.json Updating to use injector & removing storybook Jul 17, 2018
phpcs.xml.dist Add individual phpcs ruleset to Travis builds Aug 17, 2018
phpunit.xml.dist FIX Update module for latest SS4, vendorise Oct 18, 2017
readme.md Add supported module badge to readme Jun 15, 2018
webpack.config.js NEW Converting tagfield to use react components Jul 11, 2018
yarn.lock Updating yarn.lock Jul 17, 2018

readme.md

Tag Field

Custom tag input field, for SilverStripe.

Build Status SilverStripe supported module Code Quality Code coverage Version License

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

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.