Actions
Bug #99130
closedForm Variants: Dynamic validators on formValues break in PHP 8
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2022-11-18
Due date:
% Done:
0%
Estimated time:
TYPO3 Version:
11
PHP Version:
8.1
Tags:
Complexity:
Is Regression:
Sprint Focus:
Description
Since Version 8 PHP breaks when array key not exists. This affects the usage of dynamic validators of form variants as documented here:
https://docs.typo3.org/c/typo3/cms-form/11.5/en-us/I/Concepts/Variants/Index.html#adding-validators-dynamically.
When we use e.g.
condition: 'formValues["country"] == "GB"'
we get the following error
#1476107295 TYPO3\CMS\Core\Error\Exception PHP Warning: Undefined array key "country" in /var/www/html/vendor/symfony/expression-language/Node/GetAttrNode.php line 97
A possible explanation is that in TYPO3\CMS\Form\Domain\Runtime\FormRuntime , processVariants() is called a number of times (also when the form is initially rendered), but the formValues (which are filled from the formState and the request arguments, see lines 1124ff. ) remain empty until they are filled later. The condition matcher ( line 476 ) then is invoked to match the condition against an empty array with no keys, resulting in the above error.
Actions