From 8533473f8b3530de4bd06733c1d4511a85d96479 Mon Sep 17 00:00:00 2001 From: Igor Manjencic Date: Wed, 17 Jan 2024 10:55:19 +0100 Subject: [PATCH] feat(ZMS-1808): add validation --- .../Zmsadmin/WorkstationProcessRedirect.php | 22 ++++++++++++++++--- .../block/appointment/formRedirect.twig | 3 ++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/zmsadmin/src/Zmsadmin/WorkstationProcessRedirect.php b/zmsadmin/src/Zmsadmin/WorkstationProcessRedirect.php index 44478e063..d8d8d9482 100644 --- a/zmsadmin/src/Zmsadmin/WorkstationProcessRedirect.php +++ b/zmsadmin/src/Zmsadmin/WorkstationProcessRedirect.php @@ -29,9 +29,24 @@ public function readResponse( $process = $workstation->process; if ($request->getMethod() === 'POST') { + $validator = $request->getAttribute('validator'); + $selectedLocation = $validator->getParameter('location')->isNumber()->getValue(); + + if (empty($selectedLocation)) { + return \BO\Slim\Render::redirect( + 'workstationProcessRedirect', + [], + [ + 'errors' => [ + 'location' => 'Bitte wählen Sie einen Standort aus.' + ] + ] + ); + } + $scope = \App::$http ->readGetResult( - '/scope/' . $input['location'] . '/', + '/scope/' . $selectedLocation . '/', ['resolveReferences' => 2] )->getEntity(); @@ -54,7 +69,7 @@ public function readResponse( array() ); } - + return \BO\Slim\Render::withHtml( $response, 'page/workstationProcessRedirect.twig', @@ -64,7 +79,8 @@ public function readResponse( 'department' => $department, 'scope' => $workstation->scope, 'scopes' => $department->getScopeList(), - 'menuActive' => 'workstation' + 'menuActive' => 'workstation', + 'errors' => $request->getParam('errors') ) ); } diff --git a/zmsadmin/templates/block/appointment/formRedirect.twig b/zmsadmin/templates/block/appointment/formRedirect.twig index f1bd3c137..fee338aa3 100644 --- a/zmsadmin/templates/block/appointment/formRedirect.twig +++ b/zmsadmin/templates/block/appointment/formRedirect.twig @@ -21,9 +21,10 @@ {% set scopeOptionsGroup = scopeOptionsGroup|merge([{ 'name' : department.name, 'options' : scopeOptionsGroupOptions|msort('name') }]) %} {{ formgroup( - {"label": "Weiterleiten zu Standort"}, + {"label": "Weiterleiten zu Standort", "required": true, "errors": [errors.location]}, [{ "type": "select", + "required": true, "parameter": { "name": "location", "options": scopeOptionsGroup