tritum/repeatable_form_elements

Submit Cloned Upload Field throws Exception

Closed this issue · 4 comments

Usage of an upload field inside a repeatable container throws an exception.

Typo3 v11.5.33 with EXT:form v11.5.33
repeatable_form_elements v3.1.1
PHP 8.2

Tested with:
Basic Contact Form + Reatable Container with just one upload field

Submit without repeatable container is working.
Submit with repeatable container throws

Mon, 18 Dec 2023 09:51:47 +0100 [ALERT] request="a132fb9159de4" component="TYPO3.CMS.Frontend.ContentObject.Exception.ProductionExceptionHandler": Oops, an error occurred! Code: 20231218085141cc0fe76e- Exception: Exception while property mapping at property path "": Property "name" was not found in target object of type "TYPO3\CMS\Extbase\Domain\Model\FileReference"., in file [...]5/public/typo3/sysext/extbase/Classes/Property/PropertyMapper.php:122 - {"exception":"TYPO3\\CMS\\Extbase\\Property\\Exception\\InvalidTargetException: Property \"name\" was not found in target object of type \"TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference\". in [...]5/public/typo3/sysext/extbase/Classes/Property/TypeConverter/PersistentObjectConverter.php:134\nStack trace:\n#0 [...]5/public/typo3/sysext/extbase/Classes/Property/PropertyMapper.php(193): TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\PersistentObjectConverter->getTypeOfChildProperty('...', '...', Object(TYPO3\\CMS\\Extbase\\Property\\PropertyMappingConfiguration))\n#1 [...]5/public/typo3/sysext/extbase/Classes/Property/PropertyMapper.php(113): TYPO3\\CMS\\Extbase\\Property\\PropertyMapper->doMapping(Array, '...', Object(TYPO3\\CMS\\Extbase\\Property\\PropertyMappingConfiguration), Array)\n#2 [...]5/public/typo3/sysext/form/Classes/ViewHelpers/Form/UploadedResourceViewHelper.php(127): TYPO3\\CMS\\Extbase\\Property\\PropertyMapper->convert(Array, '...')\n#3 [...]5/public/typo3/sysext/form/Classes/ViewHelpers/Form/UploadedResourceViewHelper.php(84): TYPO3\\CMS\\Form\\ViewHelpers\\Form\\UploadedResourceViewHelper->getUploadedResource()\n#4 [internal function]: TYPO3\\CMS\\Form\\ViewHelpers\\Form\\UploadedResourceViewHelper->render()\n#5 [...]5/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php(256): call_user_func(Array)\n#6 [...]5/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php(244): TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper->callRenderMethod()\n#7 [...]5/vendor/typo3fluid/fluid/src/Core/ViewHelper/ViewHelperInvoker.php(79): TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper->initializeArgumentsAndRender()\n#8 [...]5/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php(507): TYPO3Fluid\\Fluid\\Core\\ViewHelper\\ViewHelperInvoker->invoke('...', Array, Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext), Object(Closure))\n#9 /html/live/deployer/shared/var/cache/code/fluid_template/partial_FileUpload_2716159b7a69ac081c8a0bf8e988b45b352047bd.php(132): TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#10 [...]5/vendor/typo3fluid/fluid/src/ViewHelpers/RenderViewHelper.php(141): partial_FileUpload_2716159b7a69ac081c8a0bf8e988b45b352047bd->{closure}()\n#11 /html/live/deployer/shared/var/cache/code/fluid_template/partial_FileUpload_2716159b7a69ac081c8a0bf8e988b45b352047bd.php(154): TYPO3Fluid\\Fluid\\ViewHelpers\\RenderViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#12 [...]5/public/typo3/sysext/form/Classes/ViewHelpers/RenderRenderableViewHelper.php(88): partial_FileUpload_2716159b7a69ac081c8a0bf8e988b45b352047bd->{closure}()\n#13 /html/live/deployer/shared/var/cache/code/fluid_template/partial_FileUpload_2716159b7a69ac081c8a0bf8e988b45b352047bd.php(165): TYPO3\\CMS\\Form\\ViewHelpers\\RenderRenderableViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#14 [...]5/vendor/typo3fluid/fluid/src/View/AbstractTemplateView.php(326): partial_FileUpload_2716159b7a69ac081c8a0bf8e988b45b352047bd->render(Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#15 [...]5/vendor/typo3fluid/fluid/src/ViewHelpers/RenderViewHelper.php(164): TYPO3Fluid\\Fluid\\View\\AbstractTemplateView->renderPartial('...', NULL, Array, false)\n#16 /html/live/deployer/shared/var/cache/code/fluid_template/partial_RepeatableContainer_2547b0b3d83200167b02981c9947075abfebf336.php(317): TYPO3Fluid\\Fluid\\ViewHelpers\\RenderViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#17 [...]5/vendor/typo3fluid/fluid/src/ViewHelpers/ForViewHelper.php(149): partial_RepeatableContainer_2547b0b3d83200167b02981c9947075abfebf336->{closure}()\n#18 /html/live/deployer/shared/var/cache/code/fluid_template/partial_RepeatableContainer_2547b0b3d83200167b02981c9947075abfebf336.php(332): TYPO3Fluid\\Fluid\\ViewHelpers\\ForViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#19 [...]5/vendor/typo3fluid/fluid/src/ViewHelpers/RenderViewHelper.php(141): partial_RepeatableContainer_2547b0b3d83200167b02981c9947075abfebf336->{closure}()\n#20 /html/live/deployer/shared/var/cache/code/fluid_template/partial_RepeatableContainer_2547b0b3d83200167b02981c9947075abfebf336.php(356): TYPO3Fluid\\Fluid\\ViewHelpers\\RenderViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#21 [...]5/public/typo3/sysext/form/Classes/ViewHelpers/RenderRenderableViewHelper.php(88): partial_RepeatableContainer_2547b0b3d83200167b02981c9947075abfebf336->{closure}()\n#22 /html/live/deployer/shared/var/cache/code/fluid_template/partial_RepeatableContainer_2547b0b3d83200167b02981c9947075abfebf336.php(368): TYPO3\\CMS\\Form\\ViewHelpers\\RenderRenderableViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#23 [...]5/vendor/typo3fluid/fluid/src/View/AbstractTemplateView.php(326): partial_RepeatableContainer_2547b0b3d83200167b02981c9947075abfebf336->render(Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#24 [...]5/vendor/typo3fluid/fluid/src/ViewHelpers/RenderViewHelper.php(164): TYPO3Fluid\\Fluid\\View\\AbstractTemplateView->renderPartial('...', NULL, Array, false)\n#25 /html/live/deployer/shared/var/cache/code/fluid_template/partial_Page_79e1fe6b8d05298ce31e91b3c800ee81be83326d.php(114): TYPO3Fluid\\Fluid\\ViewHelpers\\RenderViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#26 [...]5/vendor/typo3fluid/fluid/src/ViewHelpers/ForViewHelper.php(149): partial_Page_79e1fe6b8d05298ce31e91b3c800ee81be83326d->{closure}()\n#27 /html/live/deployer/shared/var/cache/code/fluid_template/partial_Page_79e1fe6b8d05298ce31e91b3c800ee81be83326d.php(129): TYPO3Fluid\\Fluid\\ViewHelpers\\ForViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#28 [...]5/public/typo3/sysext/form/Classes/ViewHelpers/RenderRenderableViewHelper.php(88): partial_Page_79e1fe6b8d05298ce31e91b3c800ee81be83326d->{closure}()\n#29 /html/live/deployer/shared/var/cache/code/fluid_template/partial_Page_79e1fe6b8d05298ce31e91b3c800ee81be83326d.php(140): TYPO3\\CMS\\Form\\ViewHelpers\\RenderRenderableViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#30 [...]5/vendor/typo3fluid/fluid/src/View/AbstractTemplateView.php(326): partial_Page_79e1fe6b8d05298ce31e91b3c800ee81be83326d->render(Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#31 [...]5/vendor/typo3fluid/fluid/src/ViewHelpers/RenderViewHelper.php(164): TYPO3Fluid\\Fluid\\View\\AbstractTemplateView->renderPartial('...', NULL, Array, false)\n#32 /html/live/deployer/shared/var/cache/code/fluid_template/FormFrontend_action_form_fca20b2d50d9396df536eae8f00557a52d457ff0.php(78): TYPO3Fluid\\Fluid\\ViewHelpers\\RenderViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#33 [...]5/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php(293): FormFrontend_action_form_fca20b2d50d9396df536eae8f00557a52d457ff0->{closure}()\n#34 [...]5/public/typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php(171): TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper->renderChildren()\n#35 [internal function]: TYPO3\\CMS\\Fluid\\ViewHelpers\\FormViewHelper->render()\n#36 [...]5/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php(256): call_user_func(Array)\n#37 [...]5/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php(244): TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper->callRenderMethod()\n#38 [...]5/vendor/typo3fluid/fluid/src/Core/ViewHelper/ViewHelperInvoker.php(79): TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper->initializeArgumentsAndRender()\n#39 [...]5/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php(507): TYPO3Fluid\\Fluid\\Core\\ViewHelper\\ViewHelperInvoker->invoke('...', Array, Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext), Object(Closure))\n#40 /html/live/deployer/shared/var/cache/code/fluid_template/FormFrontend_action_form_fca20b2d50d9396df536eae8f00557a52d457ff0.php(208): TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#41 [...]5/public/typo3/sysext/form/Classes/ViewHelpers/RenderRenderableViewHelper.php(88): FormFrontend_action_form_fca20b2d50d9396df536eae8f00557a52d457ff0->{closure}()\n#42 /html/live/deployer/shared/var/cache/code/fluid_template/FormFrontend_action_form_fca20b2d50d9396df536eae8f00557a52d457ff0.php(219): TYPO3\\CMS\\Form\\ViewHelpers\\RenderRenderableViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#43 [...]5/vendor/typo3fluid/fluid/src/View/AbstractTemplateView.php(184): FormFrontend_action_form_fca20b2d50d9396df536eae8f00557a52d457ff0->render(Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#44 [...]5/public/typo3/sysext/form/Classes/Domain/Renderer/FluidFormRenderer.php(189): TYPO3Fluid\\Fluid\\View\\AbstractTemplateView->render('...')\n#45 [...]5/public/typo3/sysext/form/Classes/Domain/Runtime/FormRuntime.php(695): TYPO3\\CMS\\Form\\Domain\\Renderer\\FluidFormRenderer->render()\n#46 [...]5/public/typo3/sysext/form/Classes/ViewHelpers/RenderViewHelper.php(118): TYPO3\\CMS\\Form\\Domain\\Runtime\\FormRuntime->render()\n#47 /html/live/deployer/shared/var/cache/code/fluid_template/FormFrontend_action_render_cf9d418e296bd28285f23721a03fd5270efe3f44.php(70): TYPO3\\CMS\\Form\\ViewHelpers\\RenderViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#48 [...]5/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractConditionViewHelper.php(82): FormFrontend_action_render_cf9d418e296bd28285f23721a03fd5270efe3f44->{closure}()\n#49 /html/live/deployer/shared/var/cache/code/fluid_template/FormFrontend_action_render_cf9d418e296bd28285f23721a03fd5270efe3f44.php(92): TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractConditionViewHelper::renderStatic(Array, Object(Closure), Object(TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext))\n#50 [...]5/vendor/typo3fluid/fluid/src/View/AbstractTemplateView.php(184): FormFrontend_action_render_cf9d418e296bd28285f23721a03fd5270efe3f44->render(Object(TYPO3\\CMS\\Fluid\\Cor

The problem seems to be that the request argument for the upload field returns an array instead of a file reference object...

I think I got it sorted: if you set the dataType of the renderable in FormHooks.php like this: try { $renderable->setDataType($originalProcessingRule->getDataType()); } catch (\TypeError $error) { } it seems (didn't do much testing yet) to work.

Feeling a little dumb right now: I just realized that the fix is already in git: #34

Can confirm. I am not able to reproduce this bug in our current working branch.