I’m still trying to get to grips with many_many and need a bit of help.
Say for example I had a $db field called 'Tag' on a DataObject. It is easy to adapt the examples on this page: http://doc.silverstripe.org/framework/en/howto/grouping-dataobjectsets and easily group results by a single tag per Object:
-----
Tag 1:
-----
Object 1
Object 3
-----
Tag 2:
-----
Object 2
But what I wish to do is sort according to a selection of Tags which have been added using a $many_many and this module https://github.com/chillu/silverstripe-tagfield. So, for example Object 3 may now have both 'Tag 1' and 'Tag 2' so I wish to display like:
-----
Tag 1:
-----
Object 1
Object 3
-----
Tag 2:
-----
Object 2
Object 3
To do this, I assume I have to adapt the older code for a GroupedList::create on the page, but obviously the join-table is not a DataObject, so how do I go about approaching this?
Any help at all is very appreciated, I think I have spent my whole Sunday trying to figure this out.