3460 Posts in 1064 Topics by 739 members
|Go to End|
12 January 2014 at 5:46pm
I've got an issue that I'm hoping someone can help with.
I've set up a DataExtension called BlogEntryExtension, which is applied to BlogEntry. I've also got a custom DataObject of class BlogCategory. So far so good.
$many_many = array('BlogCategories' => 'BlogCategory');
$belongs_many_many = array('BlogEntries' => 'BlogEntry');
The idea being that a BlogEntry can belong to many categories, and a category can contain multiple BlogEntries.
My issue is twofold. Firstly, I assumed that $this->owner->BlogCategories() from within BlogEntryExtension would return me the related BlogCategories. It doesn't - it returns ALL BlogCategories in the database.
Secondly, when I create a GridField Relation Editor for this relationship, it doesn't reflect the relationship, instead showing ALL BlogCategories again.
Has anyone encountered this before? Is many_many within DataExtensions not supported, or have I just misused something?
Thanks in advance.
18 January 2014 at 11:27am
many_many should be supported in extensions fine and $this->owner->BlogCategories() should get you just the relations. There isn't a method called BlogCategories on your BlogEntry or any extensions that is overriding the SilverStripe __get() is there?
|Go to Top|