From aa50edcbb00f5642f80b53563684f2303c103020 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 26 Sep 2019 06:49:13 -0400 Subject: [PATCH] Update a non-wired WireArray to automatically inherit an added item's ProcessWire instance --- wire/core/WireArray.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wire/core/WireArray.php b/wire/core/WireArray.php index febc908b..029377e9 100644 --- a/wire/core/WireArray.php +++ b/wire/core/WireArray.php @@ -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 isn’t already wired + if($this->_wire === null && $item instanceof Wire && $item->isWired()) $item->wire($this); } /**