private function cleanUpRecords($newValues)
{
if (!$this->parent->exists()) {
return;
}
$newIds = [];
foreach ($newValues as $nv) {
if (isset($nv['id']) && $nv['id'] != '') {
$newIds[] = Entity::getInstance()->getDatabase()->id($nv['id']);
}
}
$attrValues = $this->getValue();
foreach ($attrValues as $r) {
if (!in_array($r->id, $newIds)) {
$r->delete();
}
}
}