[!!!][TASK] Adapt UploadViewHelper to changes made in extbase
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Thu, 26 Jul 2012 20:27:39 +0000 (22:27 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Wed, 15 Aug 2012 21:41:49 +0000 (23:41 +0200)
This patch make UploadViewHelper compatible with handling $_FILES
in Extbase.

Upload viewHelper should be mapped to an array instead of string
from now on.

Resolves: #39303
Related: #34528

Releases: 6.0

Change-Id: If9870fd75702e951b8cf073e357b57fe408c3a15
Reviewed-on: http://review.typo3.org/13085
Reviewed-by: Nicole Cordes
Tested-by: Nicole Cordes
Reviewed-by: Ingo Pfennigstorf
Tested-by: Ingo Pfennigstorf
Reviewed-by: Markus Günther
Tested-by: Markus Günther
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/fluid/Classes/ViewHelpers/Form/UploadViewHelper.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/UploadViewHelperTest.php

index d0d498b..6cd59ae 100644 (file)
@@ -63,7 +63,10 @@ class Tx_Fluid_ViewHelpers_Form_UploadViewHelper extends Tx_Fluid_ViewHelpers_Fo
         */
        public function render() {
                $name = $this->getName();
-               $this->registerFieldNameForFormTokenGeneration($name);
+               $allowedFields = array('name', 'type', 'tmp_name', 'error', 'size');
+               foreach ($allowedFields as $fieldName) {
+                       $this->registerFieldNameForFormTokenGeneration($name . '[' . $fieldName . ']');
+               }
 
                $this->tag->addAttribute('type', 'file');
                $this->tag->addAttribute('name', $name);
index 6750a61..55dc0ec 100644 (file)
@@ -50,7 +50,13 @@ class Tx_Fluid_Tests_Unit_ViewHelpers_Form_UploadViewHelperTest extends Tx_Fluid
                $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('addAttribute', 'setContent', 'render'), array(), '', FALSE);
                $mockTagBuilder->expects($this->at(0))->method('addAttribute')->with('type', 'file');
                $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('name', 'someName');
-               $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('someName');
+
+               $this->viewHelper->expects($this->at(0))->method('registerFieldNameForFormTokenGeneration')->with('someName[name]');
+               $this->viewHelper->expects($this->at(1))->method('registerFieldNameForFormTokenGeneration')->with('someName[type]');
+               $this->viewHelper->expects($this->at(2))->method('registerFieldNameForFormTokenGeneration')->with('someName[tmp_name]');
+               $this->viewHelper->expects($this->at(3))->method('registerFieldNameForFormTokenGeneration')->with('someName[error]');
+               $this->viewHelper->expects($this->at(4))->method('registerFieldNameForFormTokenGeneration')->with('someName[size]');
+
                $mockTagBuilder->expects($this->once())->method('render');
                $this->viewHelper->injectTagBuilder($mockTagBuilder);