API to prevent empty FlexForm plugin settings being saved/merged to TypoScript settings

I’m trying to provide a solution for a well known problem with Extbase extensions and plugin FlexForm. An extension can provide TypoScript like tx_foo.settings.bar = baz. When the same setting is available in plugin FlexForm, the FlexForm value will always override the TypoScript value even if the value in FlexForm is empty (see Bug #92363: Flexform always overwrites TS-Settings in Extbase-Version - TYPO3 Core - TYPO3 Forge as an example). In ext:news @georgringer implemented a function to actually merge only those FlexForm fields, that are defined to be ignored when empty (see news/Classes/Controller/NewsController.php at main · georgringer/news · GitHub)

My idea is to provide a similar solution in TYPO3 core, which however is a little different. Instead of defining ignored override settings in TypoScript, I would define them in every FlexForm sheet in the T3DataStructure as shown below (naming is just an example).

<ignoredTypoScriptOverrideFlexFieldsIfEmptyValue type="array">
    <numIndex index="0">settings.showForgotPassword</numIndex>
    <numIndex index="1">settings.showLogoutFormAfterLogin</numIndex>

This can then either be used in DataHandler to prevent to save empty field values to pi_flexform or in FrontendConfigurationManager to ignore affected settings when TypoScript and FlexForm settings are merged.

Pro for the DataHandler solution:

  • Plugin datastructure is already resolved and

Con for the DataHandler solution:

  • Plugin Settings have to be re-saved in TYPO3 backend in order to remove ignored and empty FlexForm field values

Pro for the FrontendConfoigurationManager solution:

  • Plugin settings do not need to be re-saved

Con for the FrontendConfoigurationManager solution:

  • FlexForm needs to be resolved and parsed while rendering a plugin. This may cost more time and may be error prone (e.g. if FlexForm is somehow invalid/can not be parsed)

My general question is, if such a solution is suitable (especially if the introduction of a new T3DataStructure node)?

I’d say this is currently Extbase/FrontendConfigurationManager territory.

It would actually be nice to have that override-TypoScript-defaults-by-editor for other content, too. This would do well as an API. Maybe as a DataProcessor?

If you implement it have one special case in mind:
What if you want to overwrite for one special plugin the value from typoscript with an empty value?

Maybe have one special value/ keyword which overwrites with an empty value.

IMHO: If we want to get that “right” forever, there is no way around adding a checkbox next to each flexform field with the label “use default value”, which defaults to true.

So Extbase is actually able to decide whether the flex-field’s value is to be considered or not.
That’s the only feasible way I can think of, which covers everything from textfield, select and group fields.

(and if we want to go nuts: one more checkbox: “merge with default” :crazy_face:)

I fiddled around with this option too (the checkbox), but the mode property (https://docs.typo3.org/m/typo3/reference-tca/main/en-us/ColumnsConfig/CommonProperties/Mode.html) was never supported by FlexForm, so we can not get the checkbox to FlexForm fields with the current TYPO3 features.

Torben, thanks for addressing this. I do not want to make this more complicated, but I agree with Markus Klein and think we need a solution that works long term and with edge cases also. :smile:

(1) People above and in the issue already mentioned the problem of

  • “what is empty”
  • you can’t override a non-empty default anymore in Flexform with the solution mentioned above.
  • what about other non-text fields which do not have an “empty” state, e.g. radio buttons, check boxes etc.

I think a solution needs an exact definition of what is empty and what should override what.

Or do we want a way to set a value explicitly or leave it alone (use default from TypoScript). Also, what if there is no TypoScript? Should set to default.

Implementation can be
a) checkbox (as mentioned above), in issue and used e.g. to override the FAL metadata
b) radio buttons (override vs. use default) as used in “Translation behaviour” allowLanguageSynchronization for translated fields where you can choose the value of the record in the default language or set to a custom value.

(2) minor naming nitpick: ignoredTypoScriptOverrideFlexFieldsIfEmptyValue is not clear to me. What is ignored, what is overriden? Maybe ignoreEmptyFlexFields (if you want to not mention TypoScript) or maybe doNotSaveEmptyFlexFields* (with datahandler solution) or flexFieldsWithEmptyValueDoNotOverrideTypoScript

(3) having a separate list makes it easy to overlook. I would prefer the setting in the respective field column, e.g. as additional “doNotOverrideIfEmpy” or whatever property (would then have to be defined in TCA), just looking what would be convenient as Extension developer).

(4) Is this Extbase specific? Why not make the functionality to combine TypoScript and Flexform (or TCA in general, see 5) a generic core functionality and add this along the way?

(5) suggestion from @jonaseberle1 is also interesting, might help to see some usecases though.

100% agree. This also is no new feature, this is already in use for file references where editors are able to use the inherited value from the file record itself. Same for translations.

Immediately the typoscript constants editor comes to my mind. Can’t it be done the same way here as well?

“No new feature” is currently wrong here, since nullable values and the whole “checkbox” thing is not supported by FlexForm. I’m currently creating a POC on how we could integrate a solution with a checkbox (see screenshot)


From an admin perspective, this is exactly what is needed to prevent global TypoScript settings from being overridden. However, for editors, this checkbox has no real value and is confusing too (regardless of, if the checkbox show the global value or just a text), since it is not self explaining and an editor might not be aware of, what TypoScript is or that some plugin settings might be configured globally.

The checkbox-solution might also not be inline with the general wish to make to TYPO3 backend more clean/user friendly, but I’ll try to finish the POC so we have something to discuss on.

From an administrators perspective I see three scenarios:

  • the TypeScript value is a default and can be override via FlexForm
  • the TypeScript value cannot be overriden via FlexForm but is visible
  • the TypeScript value cannot be overriden via FlexForm but is invisible

From an editors perspective I wantto see any default value. A checkbox telling me to use the default is useless if i don’t know what is.
Furthermore if “use defaults” is checked the field must be rendered as non-editable showing the defaults. But the FlexForm should preserve whatever the editor has entered regardeless of te state of the checkbox. If the checkbox state is toggled the form must reflect this immediately or tell the user to save and reload it.

Checkboxes next to every single field will clutter up the form. So I propose that fields with TypeScript values are rendered as non-editable by default. Only if a checkbox is asked for in TypeScript (not the FlexForm) it should be rendered. Perhaps a config setting in the FlexForm will make a field with a TypeScript value non-rendered.

Remains the issue of empty strings and the number zero in TypeScript. IMHO both should be treated as distinct values different from empty.