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.

All other Modules /

Discuss all other Modules here.

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

[SOLVED]Change sort order on SubmittedFormReportField


Go to End


3 Posts   1530 Views

Avatar
NickJacobs

Community Member, 148 Posts

18 May 2009 at 3:57pm

Edited: 19/05/2009 4:35pm

Hi, can anyone tell me how I can change the order that Submitted form responses show up in the CMS?? (I just want them in descending order so that latest are at the top of the page...)

cheers

Avatar
Willr

Forum Moderator, 5523 Posts

18 May 2009 at 8:27pm

These instructions are based off userforms 0.2 but will probably work in 0.1 (with line numbers slightly diff

The function which returns the list of results is Submissions() in SubmittedFormReportField.php (line 20). Rather then just returning the values you will need to sort them then return them like this

	function Submissions() {
		$submissions = $this->form->getRecord()->Submissions();
		if($submissions) $submissions->sort('Created', 'DESC'); // sort if they exist
		return $submissions;
	}

Avatar
NickJacobs

Community Member, 148 Posts

19 May 2009 at 4:35pm

Edited: 19/05/2009 4:35pm

Great, thanks Will, thats it.