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

Custom Control fail


Go to End


3 Posts   1910 Views

Avatar
morewordsfaster

Community Member, 8 Posts

1 December 2009 at 6:45pm

This may or may not be the best place for this question, so sorry if I'm in the wrong section.

Anyway, I have created a custom page type that has a controller that should pull the submissions from another page's form and display the submissions in a table. However, the function I call from the page controller returns empty strings. Here's my code -- if anyone can shed some light, I'd greatly appreciate it :)

[in the page type declaration ViewEventsPage.php...]

class ViewEventsPage_Controller extends Page_Controller {

public function EventSubmissionResults() {
$submissions = DataObject::get('EventSubmission');
return new DataObjectSet($submissions);
}
}

[and inside the layout ViewEventsPage.ss...]

<% control EventSubmissionResults %>
<tr><td>$Type</td><td>$Details</td></tr>
<% end_control %>

Thanks again!

Avatar
Willr

Forum Moderator, 5523 Posts

1 December 2009 at 7:32pm

 DataObject::get('EventSubmission')
already returns a DataObjectSet. Try

   public function EventSubmissionResults() { 
      return DataObject::get('EventSubmission'); 
   } 

Avatar
morewordsfaster

Community Member, 8 Posts

6 December 2009 at 7:57am

Thanks a lot, Will. Works like a charm :)