From a00e546f5f7419d523ce9db204cf80c8199f3816 Mon Sep 17 00:00:00 2001 From: Ben Thomson Date: Wed, 10 Apr 2019 13:20:51 +0800 Subject: [PATCH] Clean up processItems() method --- modules/backend/formwidgets/Repeater.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/backend/formwidgets/Repeater.php b/modules/backend/formwidgets/Repeater.php index af16b9f90..fa69e371d 100644 --- a/modules/backend/formwidgets/Repeater.php +++ b/modules/backend/formwidgets/Repeater.php @@ -197,7 +197,7 @@ class Repeater extends FormWidgetBase */ protected function processItems() { - $groups = []; + $groupMap = []; $currentValue = post($this->formField->getName(), $this->getLoadValue()); // Ensure that the minimum number of items are preinitialized @@ -215,20 +215,20 @@ class Repeater extends FormWidgetBase } } - if (is_array($currentValue)) { + if (is_array($currentValue) && count($currentValue)) { foreach ($currentValue as $value) { - $groups[] = array_get($value, '_group'); + $groupMap[] = array_get($value, '_group'); } } - if (!count($groups)) { + if (!count($groupMap)) { return; } - foreach ($groups as $index => $groupCode) { + foreach ($groupMap as $index => $groupCode) { $this->makeItemFormWidget($index, $groupCode); } - $this->indexCount = max(count($groups), $this->indexCount); + $this->indexCount = max(count($currentValue), $this->indexCount); } /**