cms icon indicating copy to clipboard operation
cms copied to clipboard

[5.x] Support filtering form submissions export

Open godismyjudge95 opened this issue 7 months ago • 0 comments

This PR comes as result of a client who wanted to prefilter form submissions before exporting them. Since Statamic already has a very robust filtering system, all that was needed was to allow the filters to be parsed by the exporters.

It also reworks how the export is actually performed to be less memory intensive by using lazy loading on the query and writing to the file during the loop rather than at the end.

I will note it is not ideal the code from the two query() methods is duplicated from: https://github.com/statamic/cms/blob/5.x/src/Query/Scopes/Filters/Concerns/QueriesFilters.php and https://github.com/statamic/cms/blob/5.x/src/Http/Controllers/CP/Forms/FormSubmissionsController.php#L15-L63

It may be better to extract that filtering/ordering code into somewhere more central like the SubmissionQueryBuilder or SubmissionRepository.

I also did not see any tests in regards to the exports; let me know if I should create some.

godismyjudge95 avatar Aug 02 '25 04:08 godismyjudge95