n00n
n00n

Reputation: 664

TYPO3 CMS 7.6 LLL translation is not working for default

am working on a field which should have a default based on LLL translations.

'default' => 'LLL:EXT:myext/Resources/Private/Language/Backend.xlf:field.myfield.default',

I Would expect the value defined in the Translation, but it contains the string ''LLL:EXT:myext/Resources/Private/Language/Backend.xlf:field.myfield.default'. How can I use the LLL Translation to define the Default values in TCA?

cu n00n

Upvotes: 1

Views: 313

Answers (1)

Georg Ringer
Georg Ringer

Reputation: 7939

That is only possible by a custom FormProvider as the one of the core does not support this yet. Checkout the code

        // Special handling for eval null
        if (!empty($fieldConfig['config']['eval']) && GeneralUtility::inList($fieldConfig['config']['eval'], 'null')) {
            if (// Field exists and is set to NULL
                array_key_exists($fieldName, $databaseRow)
                // Default NULL is set, and this is a new record!
                || (array_key_exists('default', $fieldConfig['config']) && $fieldConfig['config']['default'] === null)
            ) {
                $newRow[$fieldName] = null;
            } else {
                $newRow[$fieldName] = (string)$fieldConfig['config']['default'];
            }
        } else {
            // Fun part: This forces empty string for any field even if no default is set. Unsure if that is a good idea.
            $newRow[$fieldName] = (string)$fieldConfig['config']['default'];
        }

You can open an issue at https://forge.typo3.org/projects/typo3cms-core/issues.

In the meantime, I did a small extension which makes it possible to use the desired feature. This can be found here: https://github.com/georgringer/defaultlll.

Upvotes: 2

Related Questions