Override _cleanType to handle id-keyed partial updates correctly.
Foundry's ArrayField._cleanType forces partial:false on all elements, which has two problems:
_delete (not in schema) from every element.This override:
_delete: true items (returns only idKey + _delete, skips element.clean entirely)
ArrayField subclass that supports key-based partial updates.
When an update array contains items with a key field (default
id, configurable viaidKeyoption), each item is merged into the matching existing element rather than replacing the whole array. Merging is recursive: nested arrays whose items haveidfields are also merged.Items without the key field in the update are ignored (to insert a new item, include a fresh key value). To replace the full array, omit the key from all items.
To delete an item, include
_delete: truealongside the key:{ id: "abc", _delete: true }The_deletesentinel survives Foundry's cleanData pipeline via the_cleanTypeoverride.The
_updateDiffoverride usesForcedReplacement.create(merged)(v14 replacement for the deprecated==keysyntax) so the merged result is re-applied as a full replacement on the client round-trip, ensuring deletions are not silently restored by a second_mergeIdArraypass.Param: element
The element field type
Param: options
ArrayField options
Param: options.idKey
Field name used as the merge key
Param: options.replaceInnerArrays
When true, inner arrays within a matched element are replaced outright rather than id-merged. Use this when matched elements always carry their complete inner-array state (e.g. combat downs, where the full actions list is always written). Leave false (default) for elements that send partial inner-array updates (e.g. swings, where a single trigger field may be patched).