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.

General Questions /

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

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

ComplexTableField SQL Join to get data


Reply


3 Posts   535 Views

Avatar
lozhowlett

Community Member, 146 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, 1132 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, 146 Posts

28 October 2011 at 8:59pm

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