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

History 46

  1. Gerrit Code Review pushed patch set 1 for main to change 90725 status Accepted Under Review <span data-processor="relativetime" data-value="2025-09-19T09:51:28+00:00" > 09/19/25, 09:51 </span>

  2. Garvin Hicking commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2025-09-19T11:55:09+00:00" > 09/19/25, 11:55 </span>

    Applied in changeset commit:07fe4afb9ae2023e71fc15ffbfac1ebcac7f22ea.