9215 Posts in 1860 Topics by 1451 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1240 Views |
-
Userforms - Sorting fields in CSV export

23 October 2009 at 3:47am
Hi!
When exporting the submissions of an user form to a CSV file, the order of the fields is not respected, I guess they are ordered by creation date or so… How can I get those CSV columns properly ordered? It baffles me since a <% control Fields %> outputs fields in the desired order.
Thanks in advance,
Juan -
Re: Userforms - Sorting fields in CSV export

17 March 2010 at 4:05pm
Hi Juan,
I realise this is an old post but I had the same problem and hopefully this will help someone else.
I changed the SQL statement on line 89 of SubmittedFormReportField.php from
$tmp = DB::query("SELECT DISTINCT `Name`, `Title` FROM `SubmittedFormField` LEFT JOIN `SubmittedForm` ON `SubmittedForm`.`ID` = `SubmittedFormField`.`ParentID` WHERE `SubmittedFormField`.`ParentID` IN (" . implode(',', $inClause) . ") ORDER BY `SubmittedFormField`.`ID`")
to
$tmp = DB::query("SELECT DISTINCT `Name` , `Title` FROM ( (SELECT `Name` , `Title` FROM `SubmittedFormField` LEFT JOIN `SubmittedForm` ON `SubmittedForm`.`ID` = `SubmittedFormField`.`ParentID` IN (" . implode(',', $inClause) . ") ORDER BY `SubmittedFormField`.`ID`) AS `tmp` )")
It basically forces the ordering to happen before the table is reduced with the distinct command - apparently DISTINCT and ORDER BY don't work well together.
-
Re: Userforms - Sorting fields in CSV export

8 October 2010 at 1:11pm
Hi guys,
This has been included in http://open.silverstripe.org/ticket/6072 changeset. JonoM, I've used your query, but modified it so the most recent submission ordering takes precedence. Would be nice if someone could cross-check it
Cheers,
Mateusz
| 1240 Views | ||
|
Page:
1
|
Go to Top |

