Jump to:

3429 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » DataObjectSet in DataObject

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

Page: 1
Go to End
Author Topic: 463 Views
  • ivo
    Avatar
    Community Member
    19 Posts

    DataObjectSet in DataObject Link to this post

    Hi,
    can i set a DataObjectSet in a Dataobject?

    ...
    $list = new DataObjectSet();
    foreach ($dates as $d => $data) {
    $do = new DataObject();
    $do->Date = $d;
    $do->Total = $data;
    $list->push($do);
    }

    $DO->DatesList = $list;
    return $DO;
    ...

    and in the template call it via a nested control:

    <% control DO %>
    <div>
    $ID
    <% control DatesList %>
    $Date $Total
    <% end_control %>
    <hr/>
    </div>
    <% end_control %>

    Well i tried it but it doesnt seem to work.

    Is there a alternative way to achieve something like that?

  • ivo
    Avatar
    Community Member
    19 Posts

    Re: DataObjectSet in DataObject Link to this post

    Yes you can!

    You just have to take care to assign it to the right variable! gosh
    Im Sorry

    463 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.