diff --git a/src/Controller/StaticContentController.php b/src/Controller/StaticContentController.php index affe3fd3..395736d4 100644 --- a/src/Controller/StaticContentController.php +++ b/src/Controller/StaticContentController.php @@ -134,7 +134,8 @@ class StaticContentController extends Controller $row = new StaticContent(); // set and save values - $row->setID($req->request->get('id')); + $id = $req->request->get('id'); + $row->setID($id); $row->setContent($req->request->get('content')); // validate @@ -143,6 +144,14 @@ class StaticContentController extends Controller // initialize error list $error_array = []; + // check for duplicate ID + $result = $em->getRepository(StaticContent::class)->find($id); + if ($result != null) + { + error_log($id); + $error_array['id'] = 'Duplicate ID exists.'; + } + // add errors to list foreach ($errors as $error) { $error_array[$error->getPropertyPath()] = $error->getMessage(); @@ -213,6 +222,14 @@ class StaticContentController extends Controller // initialize error list $error_array = []; + // check for duplicate ID + $result = $em->getRepository(StaticContent::class)->find($id); + if ($result != null) + { + error_log($id); + $error_array['id'] = 'Duplicate ID exists.'; + } + // add errors to list foreach ($errors as $error) { $error_array[$error->getPropertyPath()] = $error->getMessage();