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.

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

ComplexTableField SQL Join to get data


Go to End


3 Posts   780 Views

Avatar
lozhowlett

Community Member, 151 Posts

28 October 2011 at 4:08am

Hi everyone

I want to get some data from a related table to show in the result set of ComplexTableField

$tablefield = new ComplexTableField(
                 $this,
                 'Results',
                 'Result',
                 array(
                 'PositionFinished' => 'Position Finished',
                 'PointedScored' => 'Pointed Scored',
                 'CarNumber' => 'Car Number'
                 ),
                 'getCMSFields_forPopup'
             );
            $fields->addFieldToTab("Root.Content.Result Manager",$tablefield);

CarNumber exists in the table "Teams", the other fields exists in "Results". However its not displaying the correct data.

The below is the set up with results class...

static $has_one = array (
            'Event' => 'Event',
            'Team' => 'Team',
            'Season' => 'Season'
        );

and the event has many results. Any ideas why this wouldnt appear?

Cheers

Avatar
martimiz

Forum Moderator, 1391 Posts

28 October 2011 at 7:48am

You can use dot notation inyour objects summaryfields. So I think this might work:

$tablefield = new ComplexTableField(
$this,
'Results',
'Result',
array(
'PositionFinished' => 'Position Finished',
'PointedScored' => 'Pointed Scored',
'Team.CarNumber' => 'Car Number'
),
'getCMSFields_forPopup'
);
$fields->addFieldToTab("Root.Content.Result Manager",$tablefield);

Avatar
lozhowlett

Community Member, 151 Posts

28 October 2011 at 8:59pm

D'oh! Of course.... thanks :)