Closed hrasekj closed 6 years ago
Method applyDefaultValues can't set default values becouse method Nette\Forms\Form::isSubmitted() returns true, when dealing with POST request.
The solution would be dummy Form instance. This worked for me.
class FakeForm extends Nette\Forms\Form { public function getHttpData($type = null, $htmlName = null) { } } class Multiplier extends Container { ... code protected function applyDefaultValues(Container $container) { $factoryContainer = (new FakeForm())->addContainer('void'); $this->fillContainer($factoryContainer); foreach ($factoryContainer->getControls() as $name => $control) { /** @var IControl $component */ $component = $container->getComponent($name, false); if ($component) { $component->setValue($control->getValue()); } } } ... code }
Which version are you using?
Method applyDefaultValues can't set default values becouse method Nette\Forms\Form::isSubmitted() returns true, when dealing with POST request.
The solution would be dummy Form instance. This worked for me.