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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

ModelAdmin and double has_many coupling

Go to End

5 Posts   868 Views


Community Member, 59 Posts

5 November 2011 at 4:07am


I experience the following problem. I have a class that has_many of another class which has another has_many to yet another class. All classes just store things like texts, no special references to other dataobjects are used. I use ModelAdmin to control the first class.

Now everything seems to be working, however in the ModelAdmin interface, the last class does not show an Add button (in the automatically generated popupfield).

So schematically I have

Class I
..has_many Class II

Class II
.. has_one Class I
.. has_many Class III

Class III
.. has_one Class II

I think many people are struggeling with this, and I hope that this schematical sketch and the wished solution will help not only me but more people around.

Thanks in advance!


Community Member, 6 Posts

7 January 2012 at 1:08am

Hi, i have the same problem.
Did you find a solution for this problem?


Forum Moderator, 1899 Posts

7 January 2012 at 2:02am

Edited: 07/01/2012 4:13am

I always had this issue, scaffolding circular relationships. I tackle it in several ways...
1) model redesign
2) modify getCMSFields code to remove the scaffolding relations and creating them in a custom way
3) hack the code to not use the ORM and crate my own form fields


Community Member, 59 Posts

7 January 2012 at 3:40am


it's a while ago so I can't tell the precize solution, but the methods mentioned by swaiba are what I use currently to, espacially the first and second method. If you encounter a problem as I described above you must definitely wonder if your model is build logically, so if there isn't any more sufficient way to build it.
Secondly, try to overrun the default getCMSFields, as also properly explained in the tutorials like tutorial 5 on DataObject relationships. I can't immediately share knowledge on the third way mentioned by swaiba, but I can confirm that the first two are for me always enough to put focus on.

Friendly regards,


Forum Moderator, 1899 Posts

7 January 2012 at 4:14am

3) hack the code to not use the ORM and crate my own form fields

I wouldn't advise this - I have only done this in the case of double many_many relationships (which are also problematic)