From ce677f72f1189d37d5c23dcaf9fb12d7eb351f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20K=C5=99=C3=AD=C5=BE?= Date: Thu, 19 Mar 2015 10:41:36 +0100 Subject: [PATCH 1/4] Typo --- src/Kdyby/Replicator/Container.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kdyby/Replicator/Container.php b/src/Kdyby/Replicator/Container.php index 687d5ce..34fc867 100644 --- a/src/Kdyby/Replicator/Container.php +++ b/src/Kdyby/Replicator/Container.php @@ -209,7 +209,7 @@ public function createOne($name = NULL) $name = $names ? max($names) + 1 : 0; } - // Container is overriden, therefore every request for getComponent($name, FALSE) would return container + // Container is overridden, therefore every request for getComponent($name, FALSE) would return container if (isset($this->created[$name])) { throw new Nette\InvalidArgumentException("Container with name '$name' already exists."); } From 4cd9a409e75c17ee58455714a77c819a77fb7657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20K=C5=99=C3=AD=C5=BE?= Date: Wed, 25 Mar 2015 09:07:07 +0100 Subject: [PATCH 2/4] Removed unused httpRequest --- src/Kdyby/Replicator/Container.php | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/src/Kdyby/Replicator/Container.php b/src/Kdyby/Replicator/Container.php index 34fc867..94c3a0f 100644 --- a/src/Kdyby/Replicator/Container.php +++ b/src/Kdyby/Replicator/Container.php @@ -44,9 +44,6 @@ class Container extends Nette\Forms\Container /** @var array */ private $created = array(); - /** @var \Nette\Http\IRequest */ - private $httpRequest; - /** @var array */ private $httpPost; @@ -310,33 +307,6 @@ private function getHttpData() - /** - * @internal - * @param \Nette\Application\Request $request - * @return Container - */ - public function setRequest(Nette\Application\Request $request) - { - $this->httpRequest = $request; - return $this; - } - - - - /** - * @return \Nette\Application\Request - */ - private function getRequest() - { - if ($this->httpRequest !== NULL) { - return $this->httpRequest; - } - - return $this->httpRequest = $this->getForm()->getPresenter()->getRequest(); - } - - - /** * @param \Nette\Forms\Container $container * @param boolean $cleanUpGroups From 114f5d2617a28658bd3210318b684426b4517843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20K=C5=99=C3=AD=C5=BE?= Date: Thu, 19 Mar 2015 10:46:54 +0100 Subject: [PATCH 3/4] Set values anytime. Previous behaviour was hack for bug in nette/forms (see issue #19) --- src/Kdyby/Replicator/Container.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Kdyby/Replicator/Container.php b/src/Kdyby/Replicator/Container.php index 94c3a0f..ba4ecd5 100644 --- a/src/Kdyby/Replicator/Container.php +++ b/src/Kdyby/Replicator/Container.php @@ -224,11 +224,9 @@ public function createOne($name = NULL) */ public function setValues($values, $erase = FALSE, $onlyDisabled = FALSE) { - if (!$this->form->isAnchored() || !$this->form->isSubmitted()) { - foreach ($values as $name => $value) { - if ((is_array($value) || $value instanceof \Traversable) && !$this->getComponent($name, FALSE)) { - $this->createOne($name); - } + foreach ($values as $name => $value) { + if ((is_array($value) || $value instanceof \Traversable) && !$this->getComponent($name, FALSE)) { + $this->createOne($name); } } @@ -247,11 +245,7 @@ protected function loadHttpData() return; } - foreach ((array) $this->getHttpData() as $name => $value) { - if ((is_array($value) || $value instanceof \Traversable) && !$this->getComponent($name, FALSE)) { - $this->createOne($name); - } - } + $this->setValues((array) $this->getHttpData()); } From bb66a804fe78a86ce2a6cf9de5812da6ad3f70dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20K=C5=99=C3=AD=C5=BE?= Date: Thu, 19 Mar 2015 10:47:12 +0100 Subject: [PATCH 4/4] Removed unused argument --- src/Kdyby/Replicator/Container.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Kdyby/Replicator/Container.php b/src/Kdyby/Replicator/Container.php index ba4ecd5..ada2a5a 100644 --- a/src/Kdyby/Replicator/Container.php +++ b/src/Kdyby/Replicator/Container.php @@ -159,11 +159,9 @@ private function getFirstControlName() /** - * @param string $name - * * @return \Nette\Forms\Container */ - protected function createContainer($name) + protected function createContainer() { $class = $this->containerClass; return new $class();