/** * {@inheritDoc} */ public function form(PhpRenderer $view, array $options = []) { $fileInput = new File('file[__index__]'); $fileInput->setOptions(['label' => $view->translate('Upload File')]); $fileInput->setAttributes(['id' => 'media-file-input-__index__']); $field = $view->formRow($fileInput); return $field . '<input type="hidden" name="o:media[__index__][file_index]" value="__index__">'; }
/** * @group ZF2-336 */ public function testCanAddFileEnctypeFromCollectionAttribute() { $file = new Element\File('file_resource'); $file ->setOptions(array()) ->setLabel('File'); $fileCollection = new Element\Collection('collection'); $fileCollection->setOptions(array( 'count' => 2, 'allow_add' => false, 'allow_remove' => false, 'target_element' => $file, )); $this->form->add($fileCollection); $this->form->prepare(); $enctype = $this->form->getAttribute('enctype'); $this->assertNotEmpty($enctype); $this->assertEquals($enctype, 'multipart/form-data'); }