fix: scontainers edit saves existing record instead of creating new
Fixes static container admin edit flow by preserving id in hiddenFields and adding route-id fallback during save. Adds regression tests for edit/create id behavior, updates release docs (changelog/testing/CLAUDE), and appends SonarQube open issues to docs/TODO. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -184,8 +184,16 @@ class ScontainersController
|
||||
}
|
||||
|
||||
$data = $result['data'];
|
||||
$containerId = (int)($data['id'] ?? 0);
|
||||
if ($containerId <= 0) {
|
||||
$routeId = (int)\Shared\Helpers\Helpers::get('id');
|
||||
if ($routeId > 0) {
|
||||
$containerId = $routeId;
|
||||
}
|
||||
}
|
||||
|
||||
$savedId = $this->repository->save([
|
||||
'id' => (int)($data['id'] ?? 0),
|
||||
'id' => $containerId,
|
||||
'status' => $data['status'] ?? 0,
|
||||
'show_title' => $data['show_title'] ?? 0,
|
||||
'translations' => $data['translations'] ?? [],
|
||||
@@ -240,7 +248,6 @@ class ScontainersController
|
||||
];
|
||||
|
||||
$fields = [
|
||||
FormField::hidden('id', $id),
|
||||
FormField::langSection('translations', 'content', [
|
||||
FormField::text('title', [
|
||||
'label' => 'Tytul',
|
||||
@@ -283,7 +290,7 @@ class ScontainersController
|
||||
$actionUrl,
|
||||
'/admin/scontainers/list/',
|
||||
true,
|
||||
[],
|
||||
['id' => $id],
|
||||
$languages,
|
||||
$errors
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user