mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Stops nested repeaters populating from previous sibling - Fixes #1381
This commit is contained in:
parent
24860fde99
commit
d24f7252b3
@ -38,10 +38,21 @@ class Repeater extends FormWidgetBase
|
||||
*/
|
||||
protected $defaultAlias = 'repeater';
|
||||
|
||||
/**
|
||||
* @var int Count of repeated items.
|
||||
*/
|
||||
protected $indexCount = 0;
|
||||
|
||||
/**
|
||||
* @var array Collection of form widgets.
|
||||
*/
|
||||
protected $formWidgets = [];
|
||||
|
||||
/**
|
||||
* @var bool Stops nested repeaters populating from previous sibling.
|
||||
*/
|
||||
protected static $onAddItemCalled = false;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ -53,7 +64,9 @@ class Repeater extends FormWidgetBase
|
||||
'sortable',
|
||||
]);
|
||||
|
||||
$this->processExistingItems();
|
||||
if (!self::$onAddItemCalled) {
|
||||
$this->processExistingItems();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,6 +141,8 @@ class Repeater extends FormWidgetBase
|
||||
|
||||
public function onAddItem()
|
||||
{
|
||||
self::$onAddItemCalled = true;
|
||||
|
||||
$this->indexCount++;
|
||||
|
||||
$this->prepareVars();
|
||||
|
Loading…
x
Reference in New Issue
Block a user