SilverStripe module for editing tags (both in the CMS and other forms)
JavaScript PHP CSS Scheme
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
code BUG Resolve issue with numeric tags being saved Nov 24, 2016
css BUG Fix duplicate tag creation Nov 4, 2015
docs/en
js Apply canCreate permissions to Select2 for tags Jul 21, 2016
templates
tests
.editorconfig
.gitattributes
.gitignore Moved source code Apr 14, 2015
.scrutinizer.yml Added standard Scrutinizer config Nov 18, 2015
.travis.yml Added standard Travis config Nov 19, 2015
_config.php
changelog.md Update changelog for 1.3.0 May 18, 2016
code-of-conduct.md Added standard code of conduct Nov 21, 2015
composer.json Update changelog for 1.3.0 May 18, 2016
contributing.md
license.md
readme.md

readme.md

Tag Field

Custom tag input field, for SilverStripe.

Build Status Code Quality Code Coverage Version License

Requirements

  • SilverStripe 3.1 or newer
  • Database: MySQL 5+, SQLite3, Postgres 8.3, SQL Server 2008

Installing

$ composer require silverstripe/tagfield

Using

Relational Tags

class BlogPost extends DataObject {
    private static $many_many = array(
        'BlogTags' => 'BlogTag'
    );
}
class BlogTag extends DataObject {
    private static $db = array(
        'Title' => 'Varchar(200)',
    );

    private static $belongs_many_many = array(
        'BlogPosts' => 'BlogPost'
    );
}
$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

class BlogPost extends DataObject {
    private static $db = array(
        'Tags' => 'Text'
    );
}
$field = StringTagField::create(
    'Tags',
    'Tags',
    array('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.