Skip to content

Commit dab32a9

Browse files
committed
Container: only Control/Container can be added to form (BC break)
1 parent 38e0584 commit dab32a9

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
@@ -287,6 +287,10 @@ public function addComponent(
287287
?string $insertBefore = null,
288288
): static
289289
{
290+
if (!$component instanceof Control && !$component instanceof self) {
291+
throw new Nette\InvalidStateException("Component '$name' of type " . get_debug_type($component) . ' is not intended to be used in the form.');
292+
}
293+
290294
parent::addComponent($component, $name, $insertBefore);
291295
if ($this->currentGroup !== null) {
292296
$this->currentGroup->add($component);

0 commit comments

Comments
 (0)