Issue Bug Closed

#107485TranslateElementPropertyViewHelper::render(): Return value must be of type array|string, null returned

Česlav Przywara 09/18/25, 18:31 updated 12/02/25, 13:04

Description

I’m getting this error on TYPO3 13.4.18. Seems to be caused by changes in #107204.

TypeError: TYPO3\CMS\Form\ViewHelpers\TranslateElementPropertyViewHelper::render(): Return value must be of type array|string, null returned
in /[...]/typo3_src-13.4.18/typo3/sysext/form/Classes/ViewHelpers/TranslateElementPropertyViewHelper.php line 65

One way to get the error is to have a form definition with `SingleSelect` field that has:
1. `renderingOptions.translation.translatePropertyValueIfEmpty` set to false
2. `properties.prependOptionLabel` set
3. `properties.prependOptionValue` not set

The problem is (I believe) rather easy to fix. `TranslateElementPropertyViewHelper::render()` now must return `string|array`, but `TranslationService::translateFormElementValue() can return `null` as well (see the steps above), so any `null` value should be converted to an empty string in return statement on line 65:

return GeneralUtility::makeInstance(TranslationService::class)->translateFormElementValue($element, $propertyParts, $formRuntime) ?? '';

Reviews 2