Skip to content

Commit

Permalink
Using Replicator with standalone forms does not fire attached [Fixed #40
Browse files Browse the repository at this point in the history
]

The Replicator can't be used with standalone \Nette\Forms\Form (so without the UI\Form).
Problem is that attached is not triggered, so values from Request are not populated to the container.
  • Loading branch information
michallohnisky authored and fprochazka committed Aug 27, 2016
1 parent 44ba6f4 commit 62d52d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Kdyby/Replicator/Container.php
Expand Up @@ -63,6 +63,7 @@ public function __construct($factory, $createDefault = 0, $forceDefault = FALSE)
{
parent::__construct();
$this->monitor('Nette\Application\UI\Presenter');
$this->monitor('Nette\Forms\Form');

try {
$this->factoryCallback = Callback::closure($factory);
Expand Down Expand Up @@ -98,7 +99,11 @@ protected function attached($obj)
{
parent::attached($obj);

if (!$obj instanceof Nette\Application\UI\Presenter) {
if (
!$obj instanceof Nette\Application\UI\Presenter
&&
$this->form instanceof Nette\Application\UI\Form
) {
return;
}

Expand Down
6 changes: 6 additions & 0 deletions tests/KdybyTests/Replicator/Container.phpt
Expand Up @@ -222,6 +222,12 @@ class ContainerTest extends Tester\TestCase
return $config->createContainer();
}


// TODO: add tests using standalone \Nette\Forms\Form and not the UI\Form.
// https://github.com/Kdyby/Replicator/issues/40
// The Replicator can't be used with standalone \Nette\Forms\Form (so without the UI\Form).
// Problem is that attached is not triggered, so values from Request are not populated to the container.

}


Expand Down

0 comments on commit 62d52d8

Please sign in to comment.