diff --git a/src/Forms/Container.php b/src/Forms/Container.php index b0903424e..55c4724f2 100644 --- a/src/Forms/Container.php +++ b/src/Forms/Container.php @@ -267,6 +267,9 @@ public function addComponent( ?string $name, string $insertBefore = null, ): static { + if (!$component instanceof Control && !$component instanceof self) { + throw new Nette\InvalidStateException("Component '$name' of type " . gettype($component) . ' is not intended to be used in the form.'); + } parent::addComponent($component, $name, $insertBefore); if ($this->currentGroup !== null) { $this->currentGroup->add($component);