Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

[SOLVED] $many_many relationships


Go to End


1623 Views

Avatar
zenmonkey

Community Member, 545 Posts

10 September 2009 at 2:51am

Edited: 11/09/2009 5:16pm

Here's the situation I have a Product page type and Top10Page page type. The Top10Page type is supposed to hold a list of Top 10 Products, I assume for that I need a $many_many relationship.

In my Top10Page I have the following:

static $many_many = array ('Products'=>'Product');

which should establish the relationship with the Product Pages

In the Product I have

static $belongs_many_many = array('Top10Pages' => 'Top10Page');

which should establish the relationship back with the Top10Pages.

However when I dev/build it doesn't complete the process. The relationship works if its just Top10Page $has_many Product but I will have more than 1 Top10Page in system at a time. Am I missing a step?

I really don't think I understand how the $many_many relation works

EDIT Tracked down the problem to the Multi Selector Field Module