Bug #95181


FlexForm – String returned for empty sections instead of Array

Added by Pierrick Caillon about 2 years ago. Updated about 1 year ago.

Needs Feedback
Should have
Start date:
Due date:
% Done:


Estimated time:
TYPO3 Version:
PHP Version:
flexform, tceform, frontend
Is Regression:
Sprint Focus:


When using the section feature of FlexForm, and empting a section, the result parsed flexform will contain an empty string instead of an empty array.
This behaviour existed before the introduction of FlexFormService.

To reproduce, a contributor must remove all elements in a flexform section and save. The flexform will then contain:

                <field index="my_field">
                    <el index="el"></el>

In EXT:core/Classes/Service/FlexFormService.phpL49, when discovering a node named el, the parser is recursively called. When $nodeValue is an empty string, it should return an empty array. Not doing so force developers to test again empty, which can not always be done straightforwardly. It is expected to be able to test with count().

I attached an example flexform to test with.


flexform.xml (821 Bytes) flexform.xml Exemple flexform Pierrick Caillon, 2021-09-10 14:39
FlexFormService.patch (962 Bytes) FlexFormService.patch The patch Pierrick Caillon, 2021-09-10 14:39
unexpected result after changes.mp4 (2.54 MB) unexpected result after changes.mp4 Bug display video Pierrick Caillon, 2022-05-24 17:19 (1.88 KB) Temporary extension with TCA configuration Pierrick Caillon, 2022-05-24 17:20
Actions #1

Updated by Mathias Schreiber over 1 year ago

  • Sprint Focus set to Remote Sprint
Actions #2

Updated by Larry Garfield over 1 year ago

  • Status changed from New to Needs Feedback

Hi Pierrick. I'm trying to turn your examples into a test so I can make a patch for this, but I'm not entirely clear on it. There's no empty section in the XML you provided, is there?

When I run it through a test (after adding a "data" element wrapper around "sheets", and adding index attributes to sheets and sDEF to avoid parse errors), I get the same result back both with and without your patch.

Can you clarify, perhaps with a confirmed test case?

(I'm testing on `main` currently, so the future v12.)

Actions #3

Updated by Pierrick Caillon over 1 year ago

It is not when a section is declared empty in the datastructure. But after removing all elements from a declared section in a flexform instance.

Updated by Pierrick Caillon over 1 year ago

I have created the smallest possible extension to provide necessary configuration.
In the attached video, I illustrate the reproduction steps using this extension.

Should I also illustrate transformation service in frontend?

(Reproduction done using main (e97def2559e6185392d2f3089c51ced2e740327a))

Actions #5

Updated by Susanne Moog over 1 year ago

  • Complexity changed from no-brainer to medium
  • Sprint Focus changed from Remote Sprint to On Location Sprint
Actions #6

Updated by Oliver Hader about 1 year ago

  • Sprint Focus deleted (On Location Sprint)

Also available in: Atom PDF