Closed elliot-sawyer closed 4 years ago
Tested with reference project, 4.5.1. Page.php:
namespace { use gorriecoe\Link\Models\Link; use gorriecoe\LinkField\LinkField; use SilverStripe\CMS\Model\SiteTree; class Page extends SiteTree { private static $db = []; private static $has_one = [ 'TestLink' => Link::class ]; private static $many_many = [ 'ManyLinks' => Link::class ]; private static $many_many_extraFields = [ 'ManyLinks' => [ 'Sort' => 'Int' // Required for all many_many relationships ] ]; public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldsToTab( 'Root.Links', [ LinkField::create( 'TestLink', 'One link', $this ), LinkField::create( 'ManyLinks', 'Many links', $this ) ] ); return $fields; } } }
mysite.yml:
gorriecoe\Link\Models\Link: belongs_many_many: Page : Page.ManyLinks
I'm happy if you want merge this, as I'm confident your test should prove it works.
Tested with reference project, 4.5.1. Page.php:
mysite.yml: