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

What relationship to choose?


Go to End


3 Posts   864 Views

Avatar
Nobrainer Web

Community Member, 138 Posts

8 June 2012 at 7:09am

Hi devs,

I need a bit of guidance, i have a DealerHolder.php Page, that will hold DataObject Dealer.
The Dealers should be added to one DealerHolder page, and then be available on translations of this page.
What is the best way to achive this?

Right now i have a many_many relation, and it kinda works, i just need to check each dealer on each translation.
Is there som better / more correct way to achive what i'm looking for?

Avatar
novaweb

Community Member, 116 Posts

8 June 2012 at 3:37pm

I think you are wanting

DealerHolder.php

static $has_many("Dealers" => "Dealer");

Dealer.php

static $has_one("DealerHolder" => "DealerHolder");

Avatar
Nobrainer Web

Community Member, 138 Posts

14 June 2012 at 7:54pm

Hi Novaweb,

But as i see it, that does require me to add new dataobjects for each translation, which is a lot of extra work and does gives problems keeping everything in sync.

Is there something i'm not seeing?