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.

Data Model Questions /

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

Band Listing Has_Many!

Go to End



Community Member, 10 Posts

13 February 2014 at 4:59am


I am trying to create a page with three tabs which read "Friday", "Saturday" and "Sunday". Within these tabs will be a sortable gridfield with a list of bands that are playing on those respective dates.

My first effort at this ended up showing the same list of bands on each tab, but apart from that all was okay! I am guessing my problem is something to do with relationships.

I am now trying this:

class Stage extends DataObject {

private static $has_many = array (
'Bands' => 'Band'



class Band extends DataObject {

private static $db = array (
'Name' => 'Text',
'Link' => 'SiteTree'

private static $has_one = array (
'Stage' => 'Stage'

public function getCMSFields() {

$fields = new FieldList (
new TextField('Name'),
new TreeDropdownField ('Link', 'Link', 'SiteTree')

return $fields;


class LineupPage extends Page{

public function init() {

public static $db = array (
'FridayHeadline' => 'Text',
'FridayHeadlineImage' => 'Image',
'FridayHeadlineLink' => 'SiteTree',
'SaturdayHeadlineBand' => 'Text',
'SaturdayHeadlineImage' => 'Image',
'SaturdayHeadlineLink' => 'SiteTree',
'SundayHeadline' => 'Text',
'SundayHeadlineImage' => 'Image',
'SundayHeadlineLink' => 'SiteTree'

public static $has_one = array (
'FridayBands' => 'Stage',
'SaturdayBands' => 'Stage',
'SundayBands' => 'Stage'

public function getCMSFields() {
$fields = parent::getCMSFields();

$fields->removeFieldFromTab("Root.Main", "Content");

///Some code here to pull each band through it's respective stage, into individual tabs on grid fields!



Can anybody give me some pointers please?