processwire-issues
processwire-issues copied to clipboard
getChanges(true) with repeater: trigger changes for 2 consecutive save()
- Repeater is empty, I add an item, save page, getChanges(true) contains something.
- Issue: I save page again without changes and getChanges(true) contains again the same as previous.
- The third save: getChanges(true) is empty.
No issue when deleting an item, just when adding one.
Test code:
$this->addHookBefore('Pages::saveReady', function (HookEvent $event): void {
$page = $event->arguments(0);
$changes = $page->getChanges(true);
if (!array_key_exists('myRepeater', $changes)) return;
wire()->notices->message("CHANGE".print_r($changes, true));
});
Output
CHANGEArray ( [myRepeater] => Array ( [0] => [1] => ) )
- ProcessWire version: 3.0.228
Same issue with Repeater Matrix when adding an item.
Maybe this could help ? https://processwire.com/talk/topic/16407-wrong-before-and-after-values-for-repeaters-on-page-ischanged/