mirror of
https://github.com/silverstripe/silverstripe-tagfield
synced 2024-10-22 11:05:32 +02:00
9daa667415
Suggesting options from a list of tags that are already set as values makes no sense. The example code in the documentation shows that you provide an input array of options, so that should be what is used to suggest options when lazy loading. |
||
---|---|---|
client | ||
docs/en | ||
src | ||
templates/SilverStripe/TagField | ||
tests | ||
_config.php | ||
.editorconfig | ||
.eslintrc.js | ||
.gitattributes | ||
.gitignore | ||
.scrutinizer.yml | ||
.travis.yml | ||
.upgrade.yml | ||
code-of-conduct.md | ||
codecov.yml | ||
composer.json | ||
contributing.md | ||
license.md | ||
package.json | ||
phpcs.xml.dist | ||
phpunit.xml.dist | ||
readme.md | ||
webpack.config.js | ||
yarn.lock |
Tag Field
Custom tag input field, for SilverStripe.
Requirements
- SilverStripe 4.0
Installing
$ composer require silverstripe/tagfield
Using
Relational Tags
use SilverStripe\ORM\DataObject;
class BlogPost extends DataObject
{
private static $many_many = [
'BlogTags' => BlogTag::class
];
}
use SilverStripe\ORM\DataObject;
class BlogTag extends DataObject
{
private static $db = [
'Title' => 'Varchar(200)',
];
private static $belongs_many_many = [
'BlogPosts' => BlogPost::class
];
}
$field = TagField::create(
'BlogTags',
'Blog Tags',
BlogTag::get(),
$this->BlogTags()
)
->setShouldLazyLoad(true) // tags should be lazy loaded
->setCanCreate(true); // new tag DataObjects can be created
String Tags
use SilverStripe\ORM\DataObject;
class BlogPost extends DataObject
{
private static $db = [
'Tags' => 'Text',
];
}
$field = StringTagField::create(
'Tags',
'Tags',
['one', 'two'],
explode(',', $this->Tags)
);
$field->setShouldLazyLoad(true); // tags should be lazy loaded
You can find more in-depth documentation in docs/en.
Versioning
This library follows Semver. According to Semver, you will be able to upgrade to any minor or patch version of this library without any breaking changes to the public API. Semver also requires that we clearly define the public API for this library.
All methods, with public
visibility, are part of the public API. All other methods are not part of the public API. Where possible, we'll try to keep protected
methods backwards-compatible in minor/patch versions, but if you're overriding methods then please test your work before upgrading.
Reporting Issues
Please create an issue for any bugs you've found, or features you're missing.