Skip to content

Commit 41608bc

Browse files
committed
Container: only Control/Container can be added to form (BC break)
1 parent 23cbf9d commit 41608bc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Forms/Container.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ public function addComponent(
279279
?string $insertBefore = null,
280280
): static
281281
{
282+
if (!$component instanceof Control && !$component instanceof self) {
283+
throw new Nette\InvalidStateException("Component '$name' of type " . get_debug_type($component) . ' is not intended to be used in the form.');
284+
}
285+
282286
parent::addComponent($component, $name, $insertBefore);
283287
$this->currentGroup?->add($component);
284288
return $this;

0 commit comments

Comments
 (0)