Repopulate report after validation error

This commit is contained in:
Marcus Moore 2024-01-02 17:59:30 -08:00
parent d8d92a6d2c
commit 740d46a50e
No known key found for this signature in database
2 changed files with 10 additions and 1 deletions

View file

@ -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,
]);
}

View file

@ -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()