Retain true backward compatibility with early repeater

This commit is contained in:
Samuel Georges 2017-04-24 19:06:59 +10:00
parent d7ef8cdcf8
commit cb56c61e36
1 changed files with 7 additions and 3 deletions

View File

@ -151,7 +151,7 @@ class Repeater extends FormWidgetBase
*/
protected function processSaveValue($value)
{
if (!is_array($value) || !$value) {
if (!$this->useGroups || !is_array($value) || !$value) {
return $value;
}
@ -172,8 +172,8 @@ class Repeater extends FormWidgetBase
protected function processExistingItems()
{
$loadedIndexes = $loadedGroups = [];
$loadValue = $this->getLoadValue();
if (is_array($loadValue)) {
foreach ($loadValue as $index => $loadedValue) {
$loadedIndexes[] = array_get($loadedValue, '_index', $index);
@ -235,10 +235,14 @@ class Repeater extends FormWidgetBase
protected function getLoadValueFromIndex($index)
{
if (is_array($loadValue = $this->getLoadValue())) {
foreach ($loadValue as $data) {
foreach ($loadValue as $_index => $data) {
if (array_get($data, '_index') == $index) {
return $data;
}
if ($_index == $index) {
return $data;
}
}
}
}