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

many_many_extraFields with another relations


Go to End


1268 Views

Avatar
striky

Community Member, 1 Post

22 October 2015 at 4:19am

Hello,

i have three models: Machine, Package and ClosingPackage.
In Machine I have relation many_many = [ 'Packages' => 'Package' ] and additional options many_many_extraFields = [Packages' => ['MinWidth' => 'Int', 'MaxWidth' => 'Int']].
Now my question, I need define in this relation between Machine and Package additional info with model ClosingPackage. So, if I try add to many_many_extraFields model ClosingPackage like this: many_many_extraFields = [Packages' => ['MinWidth' => 'Int', 'MaxWidth' => 'Int', 'ClosingPackages' => 'ClosingPackage']], it's not working. In dev build I got error ,,DataObject::__construct passed The value 'ClosingPackages'. It's supposed to be passed an array, taken straight from the database. Perhaps you should use DataList::create()->First(); instead?".
Please, exists some way how i can define in many_many_extraFields some other model?

Thank for response, regards,

striky