Nette\Forms\Controls\UploadControl::attached PHP Method

attached() protected method

This method will be called when the component (or component's parent) becomes attached to a monitored object. Do not call this method yourself.
protected attached ( $form ) : void
return void
    protected function attached($form)
    {
        if ($form instanceof Nette\Forms\Form) {
            if (!$form->isMethod('post')) {
                throw new Nette\InvalidStateException('File upload requires method POST.');
            }
            $form->getElementPrototype()->enctype = 'multipart/form-data';
        }
        parent::attached($form);
    }

Usage Example

Esempio n. 1
0
 protected function attached($form)
 {
     parent::attached($form);
     $this->fileEntity = Objects::hasProperty($this->parent->data, $this->name) ? Objects::getProperty($this->parent->data, $this->name) : NULL;
     if ($this->fileEntity instanceof \Doctrine\Common\Collections\Collection) {
         $this->multi = true;
     }
 }
All Usage Examples Of Nette\Forms\Controls\UploadControl::attached