1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-13 18:24:57 +02:00

Update a non-wired WireArray to automatically inherit an added item's ProcessWire instance

This commit is contained in:
Ryan Cramer
2019-09-26 06:49:13 -04:00
parent e634d7a4a5
commit aa50edcbb0

View File

@@ -1892,6 +1892,8 @@ class WireArray extends Wire implements \IteratorAggregate, \ArrayAccess, \Count
protected function trackAdd($item, $key) {
if($key) {}
if($this->trackChanges()) $this->itemsAdded[] = $item;
// wire this WireArray to the same instance of $item, if it isnt already wired
if($this->_wire === null && $item instanceof Wire && $item->isWired()) $item->wire($this);
}
/**