1. Go to this page and download the library: Download silverstripe/tagfield library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
silverstripe / tagfield example snippets
use SilverStripe\ORM\DataObject;
class BlogPost extends DataObject
{
private static $many_many = [
'BlogTags' => BlogTag::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