I'm cloning a page content to another existing page.
One of the fields is a repeater, if I override the repeater with a clone from the source page, items are added to the existing ones.
If I remove all items before, the issue persists.
I have to remove items, save the page, set the new repeater and save again.
This is the working code:
$ofFromPage = $fromPage->of(false);
$ofToPage = $toPage->of(false);
$toPage->carChoicePerRound->removeAll();
// We have to save the page before to add items to the repeater, or we accumulate repeater items.
$toPage->save();
$toPage->carChoicePerRound = clone $fromPage->carChoicePerRound;
$toPage->save();
Short description of the issue
I'm cloning a page content to another existing page. One of the fields is a repeater, if I override the repeater with a clone from the source page, items are added to the existing ones. If I remove all items before, the issue persists. I have to remove items, save the page, set the new repeater and save again. This is the working code:
EDIT: just remembered I already posted a report that could be the same issue: https://github.com/processwire/processwire-issues/issues/1860
Expected behavior
Overriding repeater should replace the current one.
Setup/Environment