Skip to content

Commit

Permalink
Fix repeaters are registered without a populated item
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofandel committed Jun 11, 2024
1 parent 6d02239 commit 07af4c9
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/Http/Controllers/Admin/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1204,8 +1204,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 @@ -1238,8 +1241,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 @@ -1364,7 +1365,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 @@ -1400,8 +1401,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 Expand Up @@ -1779,7 +1778,7 @@ protected function getIndexData(array $prependScope = []): array
// @todo: use $this->filters instead of indexData.
$indexDataWithoutFilters = $this->indexData($this->request);
foreach ($indexDataWithoutFilters as $key => $value) {
if (Str::endsWith($key, 'List')) {
if ($key !== 'roleList' && Str::endsWith($key, 'List')) {
unset($indexDataWithoutFilters[$key]);
}
}
Expand Down Expand Up @@ -1923,7 +1922,7 @@ public function filters(): TableFilters
$tableFilters = TableFilters::make();

foreach ($this->indexData($this->request) as $key => $value) {
if (Str::endsWith($key, 'List')) {
if ($key !== 'roleList' && Str::endsWith($key, 'List')) {
$queryString = Str::beforeLast($key, 'List');

if ($filterKey = ($this->filters[$queryString] ?? false)) {
Expand Down

0 comments on commit 07af4c9

Please sign in to comment.