Feature #102239
openSet default values for FlexForm fields
0%
Description
Hi,
I'm trying to set a default value for a flexform field, but I don't think it is currently possible, is it?
I tried using TCAdefaults with the syntax described here: https://docs.typo3.org/m/typo3/reference-tsconfig/main/en-us/PageTsconfig/TceForm.html but I think this only applies to TCEFORM and not TCAdefaults?
If this would work with TCAdefaults, how would it work with flexform sections? I tried to change a label for a field in a flexform section via TCEFORM but didn't succeed.
Best regards
David
Updated by Gerrit Code Review about 1 year ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81548
Updated by Garvin Hicking about 1 year ago
TL;DR:
Yes, indeed using TCAdefaults for FlexForm fields is currently not possible. (You would need to adjust the <default>
attribute in the flexform for this.)
Setting a label is possible via:
TCEFORM.tt_content.pi_flexform.ghsvgcrop_svgcropdemo.sDEF.settings\.subtitle.label=Your custom label
Now the in-depth take on this.
TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowInitializeNew::setDefaultsFromPageTsConfig()
only interprets existing DB field names.
The check is done on $result.processedTca.columns.XX - so you could only access "pi_flexform" here, but not "pi_flexform.yourKey". Said
initializer doesn't know about flexforms yet.
That is performed in TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess
and you can actually see some documentation on its restrictions:
Now the problem within that Processor-Class is, that currently flexform operations don't really distinguish between fetching the current value from the database,
or from a flexform-inherited default (at least to my casual interpretation).
Generally, operating on the result set within that Processor is a bit painful.
From what I've heard, work will be done in this are in v13, so this might be addressed.
I took a very deep dive into the rabbit hole and tried to patch it just for fun. I partially succeeded (see https://review.typo3.org/c/Packages/TYPO3.CMS/+/81548),
which allows one to set:
TCAdefaults.tt_content.pi_flexform.settings\.subtitle=My override value
But sadly (due to the issues mentioned earlier) this override gets applied no matter if a record is fresh or read from the database, so that's not a helpful state.
Updated by Oliver Hader about 1 year ago
- Category set to FormEngine aka TCEforms