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 Scheme
branch: master

Merge pull request #24 from asecondwill/patch-2

Update TagField.js so tags with spaces can be added
latest commit fb049075d4
@assertchris assertchris authored

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.