diff --git a/src/Multiplier.php b/src/Multiplier.php index c08678a..730bf52 100644 --- a/src/Multiplier.php +++ b/src/Multiplier.php @@ -62,13 +62,12 @@ class Multiplier extends Container /** @var Container[] */ protected array $noValidate = []; + protected ComponentResolver $resolver; + private ?Form $form = null; private bool $attachedCalled = false; - /** @var ComponentResolver */ - protected ComponentResolver $resolver; - public function __construct(callable $factory, int $copyNumber = 1, ?int $maxCopies = null) { $this->factory = $factory; @@ -216,6 +215,7 @@ public function createCopies(bool $forceValues = false): void if ($this->created === true) { return; } + $this->created = true; if (!isset($this->resolver)) { @@ -338,7 +338,7 @@ public function setValues($values, bool $erase = false): static $this->created = false; $this->detachCreateButtons(); - $this->resolver = new ComponentResolver($this->values, $this->maxCopies, $this->minCopies); + $this->resolver = new ComponentResolver($this->values, $this->maxCopies, $this->minCopies); $this->createCopies(); } @@ -386,8 +386,8 @@ protected function isFormSubmitted(): bool protected function loadHttpData(): void { if ($this->isFormSubmitted()) { - $httpData = Arrays::get($this->form->getHttpData(), $this->getHtmlName(), []); - $this->resolver = new ComponentResolver($httpData ?? [], $this->maxCopies, $this->minCopies); + $httpData = Arrays::get($this->form->getHttpData(), $this->getHtmlName(), []); + $this->resolver = new ComponentResolver($httpData ?? [], $this->maxCopies, $this->minCopies); } }