Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
SilverStripe module for editing tags (both in the CMS and other forms)
JavaScript CSS PHP
branch: master
Failed to load latest commit information.
code Stabilized API
css Correct close button image
js Stabilized API
templates Moved source code
tests Stabilized API
.gitignore Moved source code
.travis.yml Added tests and extra ajax functionality
LICENCE Added licence file
README.md Stabilized API
_config.php Moved source code
composer.json Removed version alias

README.md

TagField Module

Build Status Code Quality

Requirements

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

Download/Information

Usage

Relational Tags

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

    static $belongs_many_many = array(
        'BlogPosts' => 'BlogPost'
    );
}
$field = new TagField(
    'BlogTags', 'Blog Tags', BlogTags::get(), $post->BlogTags()
);

$field->setShouldLazyLoad(true); // tags should be lazy loaded
$field->setCanCreate(true);      // new tag DataObjects can be created

String Tags

class BlogPost extends DataObject {
    static $db = array(
        'Tags' => 'Text'
    );
}
$field = new StringTagField(
    'BlogTags', 'Blog Tags', array('one', 'two'), explode(',', $post->Tags)
);

$field->setShouldLazyLoad(true); // tags should be lazy loaded
Something went wrong with that request. Please try again.