Disallow editing of IDs of static content #799

This commit is contained in:
Ramon Gutierrez 2024-05-05 07:14:26 +08:00
parent 48d87ae119
commit 627b3da748
2 changed files with 2 additions and 10 deletions

View file

@ -212,8 +212,7 @@ class StaticContentController extends Controller
throw $this->createNotFoundException('The item does not exist');
// set and save values
$row->setID($req->request->get('id'))
->setContent($req->request->get('content'));
$row->setContent($req->request->get('content'));
// validate
$errors = $validator->validate($row);
@ -221,13 +220,6 @@ class StaticContentController extends Controller
// initialize error list
$error_array = [];
// check for duplicate ID
$result = $em->getRepository(StaticContent::class)->find($id);
if ($result != null)
{
$error_array['id'] = 'Duplicate ID exists.';
}
// add errors to list
foreach ($errors as $error) {
$error_array[$error->getPropertyPath()] = $error->getMessage();

View file

@ -39,7 +39,7 @@
<label data-field="id">
ID:
</label>
<input type="text" name="id" class="form-control m-input" value="{{ obj.getID() }}">
<input type="text" name="id" class="form-control m-input" value="{{ obj.getID() }}" {{ mode == 'update' ? 'disabled' }}>
<div class="form-control-feedback hide" data-field="id"></div>
</div>
</div>