Bug #103162
closedThe f:form ViewHelper can not handle arrays as object attribute anymore
100%
Description
Before adding strict types in V12 the <f:form> ViewHelper could be utilized with arrays as object attribute values.
<f:form objectName="q" object="{array}">
Since V12 this will throw a TypeError because the method signature of the AbstractFormViewHelper has changed and does only allow ?object parameters, which is not consistent with the viewhelper argument type (mixed), that does not implicitly say, that arrays are not to be used.
I personally often utilize the <f:form> viewhelper with arrays to handle simple search forms, because it will produce correct argument names for the form fields. If i would instead use a simple html <form> i would have to make sure to name all of my fields correctly.
IMO the parameter type should be changed from ?object to object|array|null
Unions are possible since PHP 8.0
Updated by Philipp Wrann 10 months ago
The bug has been introduced with this commit:
https://github.com/TYPO3/typo3/commit/528b90fea50622784dfdd2d651a6486e960b7460
IMO it is a bad practice to change things, that are not related to the current task, the method signature should have not been changed with the task described in the commit.
Please change the parameter type to the union described in the issue, otherwise i will need to create proxy ArrayObject classes foreach plugin where i used this very common pattern.
Updated by Florian Rival 2 months ago ยท Edited
Same problem for me, I cannot use array with formViewHelper <f:form> since TYPO3 V12 and PHP 8.2
In my use case, data are coming from a query, it could be a common use case.
Any plan to get it work again ?
Updated by Garvin Hicking 2 months ago
There was a dupe where it is addressed:
https://review.typo3.org/c/Packages/TYPO3.CMS/+/86367
Please vote on it to get it addressed.
Updated by Garvin Hicking 2 months ago
- Has duplicate Bug #105146: TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewHelper::renderHiddenIdentityField(): Argument #1 ($object) must be of type ?object, array given added
Updated by Gerrit Code Review 2 months ago
- Status changed from New to Under Review
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86367
Updated by Gerrit Code Review 2 months ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86367
Updated by Gerrit Code Review 2 months ago
Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86476
Updated by Garvin Hicking 2 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 75e7752bbddb122e9b1d8f14189f0a7629be2fa1.