Project

General

Profile

Actions

Bug #103162

open

The f:form ViewHelper can not handle arrays as object attribute anymore

Added by Philipp Wrann 2 months ago. Updated 2 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Fluid
Start date:
2024-02-20
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

Actions #1

Updated by Philipp Wrann 2 months ago

The bug has been introduced with this commit:
https://github.com/TYPO3/typo3/commit/528b90fea50622784dfdd2d651a6486e960b7460

https://github.com/TYPO3/typo3/commit/528b90fea50622784dfdd2d651a6486e960b7460#diff-c237bc764df37d84f5d4c6bd6821ea8d9b90bd809ef4110a1d4c5e6ac15b7607L80

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.

Actions

Also available in: Atom PDF