public function initialize() { $image = new Upload('fake_file'); $image->setModel(new FakeFileModel()); $image->setPreviewSize(array('width' => 100, 'height' => 100)); $image->getDecorator()->setTemplateName('jquery'); $image->setUploadUrl($this->url->get(['for' => 'testcrud', 'action' => 'upload'])); $image->setMode(Upload::MODE_MULTI); $image->setMaxFiles(3); $image->setExtensions(['jpg', 'png']); $image->setMimeTypes(['image/jpeg', 'image/png']); $image->setRenderPreview(true); $image->setLabel('Image'); $image->getDecorator()->setDI($this->di); $image->setAutoUpload(false); $image->setButtonLabels(array('add' => 'Add image')); $image->setTriggerType('button'); $image->setMaxFileSize('10MB'); $this->add($image); $field = new Text('fake_field'); $field->addValidator(new PresenceOf()); $this->add($field); }