From 7fb2258582afaeaadd3a6c300d6695579799aacf Mon Sep 17 00:00:00 2001 From: Arthur Perton Date: Fri, 7 Oct 2022 10:49:49 +0200 Subject: [PATCH 1/2] Update entry publish form values after saving --- resources/js/components/entries/PublishForm.vue | 1 + .../Controllers/CP/Collections/EntriesController.php | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/resources/js/components/entries/PublishForm.vue b/resources/js/components/entries/PublishForm.vue index 1b7f47ce74..ffdd133f4a 100644 --- a/resources/js/components/entries/PublishForm.vue +++ b/resources/js/components/entries/PublishForm.vue @@ -518,6 +518,7 @@ export default { // the hooks are resolved because if this form is being shown in a stack, we only // want to close it once everything's done. else { + this.values = { ...this.values, ...response.data.data.values }; this.initialPublished = response.data.data.published; this.activeLocalization.published = response.data.data.published; this.activeLocalization.status = response.data.data.status; diff --git a/src/Http/Controllers/CP/Collections/EntriesController.php b/src/Http/Controllers/CP/Collections/EntriesController.php index a12b91964d..508ded8bd9 100644 --- a/src/Http/Controllers/CP/Collections/EntriesController.php +++ b/src/Http/Controllers/CP/Collections/EntriesController.php @@ -240,7 +240,14 @@ public function update(Request $request, $collection, $entry) $entry->updateLastModified(User::current())->save(); } - return new EntryResource($entry->fresh()); + [$values] = $this->extractFromFields($entry, $blueprint); + + return (new EntryResource($entry->fresh())) + ->additional([ + 'data' => [ + 'values' => array_merge($values, ['id' => $entry->id()]), + ], + ]); } public function create(Request $request, $collection, $site) From 234c279621d972a157d525ca19d4a78f31dc36e8 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Wed, 26 Oct 2022 13:51:21 -0400 Subject: [PATCH 2/2] id not needed, it'll already be there, and isnt changing --- src/Http/Controllers/CP/Collections/EntriesController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Http/Controllers/CP/Collections/EntriesController.php b/src/Http/Controllers/CP/Collections/EntriesController.php index 508ded8bd9..115d354437 100644 --- a/src/Http/Controllers/CP/Collections/EntriesController.php +++ b/src/Http/Controllers/CP/Collections/EntriesController.php @@ -245,7 +245,7 @@ public function update(Request $request, $collection, $entry) return (new EntryResource($entry->fresh())) ->additional([ 'data' => [ - 'values' => array_merge($values, ['id' => $entry->id()]), + 'values' => $values, ], ]); }