0

Database records with FlexForm columns don't auto-upgrade when new fields are added in the flexform. When adding a new select field in a plugin configuration (or a flux content element), I can't rely on the field having the default value in all content elements - because the values of newly added fields are only stored in the database when editing the content elements. This makes code larger because I have to account for not-yet-existing values.

Example: A "color" select field with a default value that we just output into a class attribute:

<a class="{settings.color}">...</a>

Putting a check/switch in there makes the code much more verbose and unreadable.

What would be a good way to adjust the database records of existing (plugin) content elements when flexforms change?


The lowlevel cleanup:flexforms command only removes values for non-existing fields AFAIK.

3
  • Not sure if this works for all types, but I found in the code: The command cleanup:flexforms uses FlexFromTools-> cleanFlexFormXML which writes back missing values: github.com/TYPO3/typo3/blob/… Commented Sep 8 at 8:27
  • No, just tried it: When adding a new select and number field to plugin flexform, cleanup:flexforms does not add those to the database. Only when removing fields from flexform - those fields get removed from database. Commented Sep 8 at 11:33
  • OK. Thanks for checking this. Commented Sep 9 at 6:35

1 Answer 1

0

I personally would never rely on any free xml data comming from a flexform field, but always work with strong defaults while handling those data. E.g. in a switch-case use the default-case for the expected default.

Sign up to request clarification or add additional context in comments.

2 Comments

We're doing this, and this is causing problems because of unnecessary code. Think e.g. of a "color" field with a default value that you just output into a class attribute: <a class="{settings.color}">...</a> - putting a switch in there makes the code much more verbose.
I can think of something like '<a class="{f:if(condition:'{settings.color}, then: '{settings.color', else: 'default-color-class''}' or even simpler '<a class="default-color {settings.color}">...'

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.