Skip to content

Commit 6d25593

Browse files
committed
Container: only Control/Container can be added to form (BC break)
1 parent 4c37bb9 commit 6d25593

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
@@ -275,6 +275,10 @@ public function addComponent(
275275
?string $name,
276276
?string $insertBefore = null,
277277
): static {
278+
if (!$component instanceof Control && !$component instanceof self) {
279+
throw new Nette\InvalidStateException("Component '$name' of type " . gettype($component) . ' is not intended to be used in the form.');
280+
}
281+
278282
parent::addComponent($component, $name, $insertBefore);
279283
if ($this->currentGroup !== null) {
280284
$this->currentGroup->add($component);

0 commit comments

Comments
 (0)