Go to file
Christopher Pitt 5473c94a58 Merge pull request #29 from dhensby/patch-1
Move to new travis containerised infrastructure
2015-07-21 08:40:35 +12:00
code Stabilized API 2015-05-22 15:22:13 +12:00
css Correct close button image 2015-04-24 04:33:07 +12:00
js Update TagField.js so tags with spaces can be added 2015-05-28 10:36:06 +01:00
templates Moved source code 2015-04-14 13:15:28 +12:00
tests Stabilized API 2015-05-22 15:22:13 +12:00
_config.php Moved source code 2015-04-14 13:15:28 +12:00
.gitignore Moved source code 2015-04-14 13:15:28 +12:00
.travis.yml Move to new travis containerised infrastructure 2015-07-20 16:07:46 +01:00
composer.json Removed version alias 2015-05-25 09:03:49 +12:00
LICENCE Added licence file 2015-05-25 08:50:29 +12:00
README.md Stabilized API 2015-05-22 15:22:13 +12:00

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