mirror of
https://github.com/silverstripe/silverstripe-tagfield
synced 2024-10-22 11:05:32 +02:00
989e7cae08
The separator is hard coded as space or comma. Not much is lost if you just delete the space separator option. This allows people to add eg "Web Developer" as a job title tag. |
||
---|---|---|
code | ||
css | ||
js | ||
templates | ||
tests | ||
_config.php | ||
.gitignore | ||
.travis.yml | ||
composer.json | ||
LICENCE | ||
README.md |
TagField Module
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