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.

Data Model Questions /

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

DataObjectSet in DataObject


Go to End


2 Posts   1104 Views

Avatar
ivo

Community Member, 19 Posts

13 January 2012 at 5:11am

Edited: 13/01/2012 5:12am

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?

Avatar
ivo

Community Member, 19 Posts

13 January 2012 at 5:21am

Yes you can!

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