Jump to:

3448 Posts in 1062 Topics by 738 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Custom Control fail

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

Page: 1
Go to End
Author Topic: 1388 Views
  • morewordsfaster
    Avatar
    Community Member
    8 Posts

    Custom Control fail Link to this post

    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!

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Custom Control fail Link to this post

    DataObject::get('EventSubmission')

    already returns a DataObjectSet. Try

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

  • morewordsfaster
    Avatar
    Community Member
    8 Posts

    Re: Custom Control fail Link to this post

    Thanks a lot, Will. Works like a charm

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