Jump to:

23483 Posts in 18976 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » ComplexTableField SQL Join to get data

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

Page: 1
Go to End
Author Topic: 472 Views
  • lozhowlett
    Avatar
    Community Member
    146 Posts

    ComplexTableField SQL Join to get data Link to this post

    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

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: ComplexTableField SQL Join to get data Link to this post

    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);

  • lozhowlett
    Avatar
    Community Member
    146 Posts

    Re: ComplexTableField SQL Join to get data Link to this post

    D'oh! Of course.... thanks

    472 Views
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.