mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Merge pull request #4336 from octobercms/master
Fix group index mapping in Repeater widget (#4334)
This commit is contained in:
commit
bcd5156497
@ -217,9 +217,7 @@ class Repeater extends FormWidgetBase
|
||||
$this->indexCount = 0;
|
||||
$this->formWidgets = [];
|
||||
return;
|
||||
}
|
||||
|
||||
$groupMap = [];
|
||||
}
|
||||
|
||||
// Ensure that the minimum number of items are preinitialized
|
||||
// ONLY DONE WHEN NOT IN GROUP MODE
|
||||
@ -235,20 +233,15 @@ class Repeater extends FormWidgetBase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($currentValue) && count($currentValue)) {
|
||||
foreach ($currentValue as $value) {
|
||||
$groupMap[] = array_get($value, '_group');
|
||||
}
|
||||
}
|
||||
|
||||
if (!count($groupMap)) {
|
||||
|
||||
if (!is_array($currentValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($groupMap as $index => $groupCode) {
|
||||
$this->makeItemFormWidget($index, $groupCode);
|
||||
}
|
||||
|
||||
collect($currentValue)->each(function ($value, $index) {
|
||||
$this->makeItemFormWidget($index, array_get($value, '_group', null));
|
||||
});
|
||||
|
||||
$this->indexCount = max(count($currentValue), $this->indexCount);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user