diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index fecb87daea..43e2128d17 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -393,11 +393,18 @@ class ReportsController extends Controller $this->authorize('reports.view'); $customfields = CustomField::get(); $report_templates = ReportTemplate::orderBy('name')->get(); + $template = new ReportTemplate; + + // Set the report's input values if we were redirected back with + // validation errors so the report is populated as expected. + if ($request->old()) { + $template->options = $request->old(); + } return view('reports/custom', [ 'customfields' => $customfields, 'report_templates' => $report_templates, - 'reportTemplate' => new ReportTemplate, + 'reportTemplate' => $template, ]); } diff --git a/tests/Feature/ReportTemplates/ReportTemplateTest.php b/tests/Feature/ReportTemplates/ReportTemplateTest.php index 15c0844992..275de727e7 100644 --- a/tests/Feature/ReportTemplates/ReportTemplateTest.php +++ b/tests/Feature/ReportTemplates/ReportTemplateTest.php @@ -74,6 +74,8 @@ class ReportTemplateTest extends TestCase // that selecting fields in the UI, then getting redirected // back after hitting the "Save Template" button without // a name set restores the previously selected values. + + // Note: This functionality is implemented in getCustomReport(). } public function testSavingReportTemplateRequiresCorrectPermission()