-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Description
Short description of the issue
In this hook, removeAll() is not removing until I comment out last line (set clone).
Actually after page saved, repeater contains new items AND previous items. I can't find a way to remove all.
protected static function onSaveReady(HookEvent $event, EveningRacePage $page, mixed $eventObject): void
{
if (!self::getChanges($page)->has('raceSessionsTemplate')) {
return;
}
/** @var RaceSessionsTemplatePage $sessionsTemplate */
$sessionsTemplate = $page->raceSessionsTemplate;
$page->raceSessions->removeAll(); // removeAll() alone works...
// $page->raceSessions = null;
$page->raceSessions = clone $sessionsTemplate->raceSessions; // ... but it doesn't work when this line is there.
}
This is probably the same issue as in this report: #1959
Expected behavior
Having only new items.
Actual behavior
Having both previous and new items.
Optional: Screenshots/Links that demonstrate the issue
Workaround
$page->raceSessions->removeAll();
foreach ($sessionsTemplate->raceSessions as $raceSession){
$page->raceSessions->add($raceSession);
}
Setup/Environment
- ProcessWire version: 3.0.228


