Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix repeaters are registered without a populated item #2605

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Http/Controllers/Admin/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,7 @@ public function edit(TwillModelContract|int $id): mixed
$this->setBackLink();

$controllerForm = $this->getForm($item);
$controllerForm->registerDynamicRepeaters();

if ($controllerForm->hasForm()) {
$view = 'twill::layouts.form';
Expand All @@ -1221,8 +1222,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)]
);
}

Expand Down Expand Up @@ -1255,8 +1259,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)]
);
Expand Down Expand Up @@ -1381,7 +1383,7 @@ public function preview(int $id): IlluminateView

/**
* @param int $id
* @return \Illuminate\View\View
* @return \Illuminate\Contracts\View\View
*/
public function restoreRevision($id)
{
Expand Down Expand Up @@ -1417,8 +1419,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))]
);
Expand Down
Loading