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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

Sort ComplexTableField in the CMS


Go to End


2 Posts   2468 Views

Avatar
MarioHofer

Community Member, 107 Posts

22 June 2009 at 2:41am

Edited: 22/06/2009 9:35am

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!

Avatar
MarioHofer

Community Member, 107 Posts

22 June 2009 at 9:34am

Edited: 22/06/2009 9:34am

Ahhh, that's how it works:

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