/** * @param \Nette\ComponentModel\Container $parent * @throws \Nette\InvalidStateException * @return void */ protected function attached($parent) { if ($parent instanceof Nette\Forms\Form) { if ($parent->getMethod() !== Nette\Forms\Form::POST) { throw new Nette\InvalidStateException('File upload requires method POST.'); } $parent->getElementPrototype()->enctype = 'multipart/form-data'; } elseif ($parent instanceof Nette\Application\UI\Presenter) { if (!$this->httpRequest) { $this->httpRequest = $parent->getContext()->httpRequest; $this->httpResponse = $parent->getContext()->httpResponse; } } parent::attached($parent); }