Jump to:

3373 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Sort ComplexTableField in the CMS

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

Page: 1
Go to End
Author Topic: 1896 Views
  • theGermaniac
    Avatar
    Community Member
    82 Posts

    Sort ComplexTableField in the CMS Link to this post

    Hi,

    I've got a simple news section made with DataObjects. Everything works fine, I just want to sort the entries by date.

    $newsTable = new ComplexTableField(
       $this,
       'NewsArticles',
       'NewsArticle',
       array(
          'ArticleDate' => 'Article Date',
          'ArticleTitle' => 'Article Title'
       ),
       null
    );

    Can anyone give me a hint? Thanks!

  • theGermaniac
    Avatar
    Community Member
    82 Posts

    Re: Sort ComplexTableField in the CMS Link to this post

    Ahhh, that's how it works:

    $newsTable = new ComplexTableField(
       $this,
       'NewsArticles',
       'NewsArticle',
       array(
          'ArticleDate' => 'Article Date',
          'ArticleTitle' => 'Article Title'
       ),
       null,
       null,
       'ArticleDate DESC'
    );

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