Add checking for duplicate ID. #298
This commit is contained in:
parent
2aed73b2d5
commit
91e495f251
1 changed files with 18 additions and 1 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue