From 220a92054d383e48fe54531d7c2eec9547801691 Mon Sep 17 00:00:00 2001 From: Martin Eiber Date: Tue, 21 Mar 2023 12:22:21 +0100 Subject: [PATCH] Update a non-existing filter shows an error message. --- .../Admin/Customers/FilterDefinitionController.php | 9 +++++++++ src/Resources/translations/admin.en.yml | 1 + 2 files changed, 10 insertions(+) diff --git a/src/Controller/Admin/Customers/FilterDefinitionController.php b/src/Controller/Admin/Customers/FilterDefinitionController.php index 68b084d6..725cd875 100644 --- a/src/Controller/Admin/Customers/FilterDefinitionController.php +++ b/src/Controller/Admin/Customers/FilterDefinitionController.php @@ -115,6 +115,15 @@ public function updateAction(Request $request, CustomerViewInterface $customerVi { // fetch object parameters from request $filterDefinition = $this->getFilterDefinitionFromRequest($request, true, true); + + // check if a filter is selected + if (empty($filterDefinition)) { + // add error message for missing filter + $errors[] = $customerView->translate('cmf_filter_definition_errors_filter_missing'); + + return $this->getRedirectToFilter(0, $errors); + } + // check mandatory FilterDefinition name if (empty($filterDefinition->getName())) { // add error message for missing filter name diff --git a/src/Resources/translations/admin.en.yml b/src/Resources/translations/admin.en.yml index 81184f57..2f414e17 100644 --- a/src/Resources/translations/admin.en.yml +++ b/src/Resources/translations/admin.en.yml @@ -116,6 +116,7 @@ cmf_filter_definition_errors_access: "Not allowed to access filter." cmf_filter_definition_errors_change: "Not allowed to change filter." cmf_filter_definition_errors_deletion_failed: "Deletion of filter failed. (%s)" cmf_filter_definition_errors_name_missing: "Please provide a filter name." +cmf_filter_definition_errors_filter_missing: "Please select a filter." cmf_filter_definition_errors_save_failed: "Save of filter failed. (%s)" cmf_filter_definition_errors_share_failed: "Sharing filter failed. (%s)"