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 PHP CSS Scheme
Branch: master

Merge pull request #38 from davidjeliba/master

Fixed issue where empty keywords field would be passed to array functions as a string
latest commit fc3e96a41b
@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 = TagField::create(
    'BlogTags',
    'Blog Tags',
    BlogTag::get(),
    $post->BlogTags()
)
    ->setShouldLazyLoad(true) // tags should be lazy loaded
    ->setCanCreate(true);      // new tag DataObjects can be created

String Tags

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

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