From e3022a8a043844d0cb8f69e393037e55e1a39709 Mon Sep 17 00:00:00 2001 From: Tofandel Date: Tue, 11 Jun 2024 18:17:23 +0200 Subject: [PATCH] Fix repeaters are registered without a populated item --- src/Http/Controllers/Admin/ModuleController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Http/Controllers/Admin/ModuleController.php b/src/Http/Controllers/Admin/ModuleController.php index 731c8bbd6..4a738a3f3 100644 --- a/src/Http/Controllers/Admin/ModuleController.php +++ b/src/Http/Controllers/Admin/ModuleController.php @@ -1183,6 +1183,7 @@ public function edit(TwillModelContract|int $id): mixed $this->setBackLink(); $controllerForm = $this->getForm($item); + $controllerForm->registerDynamicRepeaters(); if ($controllerForm->hasForm()) { $view = 'twill::layouts.form'; @@ -1204,8 +1205,11 @@ public function edit(TwillModelContract|int $id): mixed } } - return View::make($view, $this->form($id))->with( - ['formBuilder' => $controllerForm->toFrontend($this->getSideFieldsets($item))] + $sideFieldsets = $this->getSideFieldsets($item); + $sideFieldsets->registerDynamicRepeaters(); + + return View::make($view, $this->form($id, $item))->with( + ['formBuilder' => $controllerForm->toFrontend($sideFieldsets)] ); } @@ -1238,8 +1242,6 @@ public function create(int $parentModuleId = null): JsonResponse|RedirectRespons return View::exists($view); }); - View::share('form', $this->form(null)); - return View::make($view, $this->form(null))->with( ['formBuilder' => $controllerForm->toFrontend($this->getSideFieldsets($emptyModelInstance), true)] ); @@ -1364,7 +1366,7 @@ public function preview(int $id): IlluminateView /** * @param int $id - * @return \Illuminate\View\View + * @return \Illuminate\Contracts\View\View */ public function restoreRevision($id) { @@ -1400,8 +1402,6 @@ public function restoreRevision($id) ); } - View::share('form', $this->form($id, $item)); - return View::make($view, $this->form($id, $item))->with( ['formBuilder' => $controllerForm->toFrontend($this->getSideFieldsets($item))] );