Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Band Listing Has_Many!

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

Page: 1
Go to End
Author Topic: 311 Views
  • Jaymonkey
    Community Member
    10 Posts

    Band Listing Has_Many! Link to this post


    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?

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.