typo3 flexform for plugin with folders

237 Views Asked by At

I have created a plugin for an extension + some Flexform for this plugin (not TCA). This works so far.

Now I would like to extend the backend view of this plugin and use several folders for the flexform. Unfortunately I don't get this working. What I tried so far is to have two structures inside <sheets> This is a structure just to get it working with the two folders. The fields will be specified in more detail once the setup with the folders will work!

<T3DataStructure>
  <meta>
    <langDisable>1</langDisable>
  </meta>
  <sheets>
    <Folder1>
    <sDEF>
      <ROOT>
        <TCEforms>
          <sheetTitle>Folder1</sheetTitle>
        </TCEforms>
        <type>array</type>
        <el>
          <settings.flexform.field11>
            <TCEforms>
              <exclude>1</exclude>
              <label>Field11</label>
              <onChange>reload</onChange>
              <config>
                <type>input</type>
                <size>30</size>
              </config>
            </TCEforms>
          </settings.flexform.field11>
          <settings.flexform.field12>
            <TCEforms>
              <exclude>1</exclude>
              <label>Field12</label>
              <config>
                <type>input</type>
                <size>30</size>
              </config>
            </TCEforms>
          </settings.flexform.field12>
        </el>
      </ROOT>
    </sDEF>
    </Folder1>
    <Folder2>
    <sDEF>
      <ROOT>
        <TCEforms>
          <sheetTitle>Folder2</sheetTitle>
        </TCEforms>
        <type>array</type>
        <el>
          <settings.flexform.field21>
            <TCEforms>
              <exclude>1</exclude>
              <label>Field21</label>
              <onChange>reload</onChange>
              <config>
                <type>input</type>
                <size>30</size>
              </config>
            </TCEforms>
          </settings.flexform.field21>
          <settings.flexform.field22>
            <TCEforms>
              <exclude>1</exclude>
              <label>Field22</label>
              <config>
                <type>input</type>
                <size>30</size>
              </config>
            </TCEforms>
          </settings.flexform.field22>
        </el>
      </ROOT>
    </sDEF>
    </Folder1>
  </sheets>
</T3DataStructure>

Update: based on answer of Julian Hofmann my structure now looks like:

<T3DataStructure>
  <meta>
    <langDisable>1</langDisable>
  </meta>
  <sheets>
    <sDEF>
    <Folder1>
      <ROOT>
        <TCEforms>
          <sheetTitle>Folder1</sheetTitle>
        </TCEforms>
        <type>array</type>
        <el>
          <settings.flexform.field11>
            <TCEforms>
              <exclude>1</exclude>
              <label>Field11</label>
              <onChange>reload</onChange>
              <config>
                <type>input</type>
                <size>30</size>
              </config>
            </TCEforms>
          </settings.flexform.field11>
          <settings.flexform.field12>
            <TCEforms>
              <exclude>1</exclude>
              <label>Field12</label>
              <config>
                <type>input</type>
                <size>30</size>
              </config>
            </TCEforms>
          </settings.flexform.field12>
        </el>
      </ROOT>
    </Folder1>
    <Folder2>
      <ROOT>
        <TCEforms>
          <sheetTitle>Folder2</sheetTitle>
        </TCEforms>
        <type>array</type>
        <el>
          <settings.flexform.field21>
            <TCEforms>
              <exclude>1</exclude>
              <label>Field21</label>
              <onChange>reload</onChange>
              <config>
                <type>input</type>
                <size>30</size>
              </config>
            </TCEforms>
          </settings.flexform.field21>
          <settings.flexform.field22>
            <TCEforms>
              <exclude>1</exclude>
              <label>Field22</label>
              <config>
                <type>input</type>
                <size>30</size>
              </config>
            </TCEforms>
          </settings.flexform.field22>
        </el>
      </ROOT>
    </Folder2>
    </sDEF>
  </sheets>
</T3DataStructure>

I now get:

PHP Warning: Undefined array key "ROOT" in /var/www/html/averlon.de/av_t3test/public/typo3/sysext/backend/Classes/Form/Container/FlexFormNoTabsContainer.php line 62
1

There are 1 best solutions below

4
Kay R. On BEST ANSWER

A Working Example based from Extension News:

https://github.com/georgringer/news/blob/main/Configuration/FlexForms/flexform_tag_list.xml

<T3DataStructure>
    <sheets>
        <!--
            ################################
              Tab 1
            ################################
        -->
        <sDEF>
            <ROOT>
                <TCEforms>
                    <sheetTitle>TAB 1</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>
                    <!-- order -->
                    <settings.orderBy>
                        <TCEforms>
                            <label>orderBy</label>
                            <config>
                                <type>select</type>
                                <renderType>selectSingle</renderType>
                                <items>
                                    <numIndex index="0" type="array">
                                        <numIndex index="0"></numIndex>
                                        <numIndex index="1"></numIndex>
                                    </numIndex>
                                    <numIndex index="1">
                                        <numIndex index="0">tstamp</numIndex>
                                        <numIndex index="1">tstamp</numIndex>
                                    </numIndex>
                                    <numIndex index="3">
                                        <numIndex index="0">crdate</numIndex>
                                        <numIndex index="1">crdate</numIndex>
                                    </numIndex>
                                    <numIndex index="4">
                                        <numIndex index="0">title</numIndex>
                                        <numIndex index="1">title</numIndex>
                                    </numIndex>
                                </items>
                            </config>
                        </TCEforms>
                    </settings.orderBy>
                </el>
            </ROOT>
        </sDEF>
        <!--
            ################################
              Tab 2
            ################################
        -->
        <additional>
            <ROOT>
                <TCEforms>
                    <sheetTitle>Tab 2</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>
                    <settings.media.maxWidth>
                        <TCEforms>
                            <label>mediaMaxWidth</label>
                            <config>
                                <type>input</type>
                                <size>5</size>
                                <eval>num</eval>
                            </config>
                        </TCEforms>
                    </settings.media.maxWidth>
                </el>
            </ROOT>
        </additional>

        <!--
            ################################
              Tab 3
            ################################
        -->
        <template>
            <ROOT>
                <TCEforms>
                    <sheetTitle>Tab 3</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>
                    <!-- Template Layout -->
                    <settings.templateLayout>
                        <TCEforms>
                            <label>templateLayout</label>
                            <config>
                                <type>select</type>
                                <renderType>selectSingle</renderType>
                                <items>
                                    <numIndex index="0" type="array">
                                        <numIndex index="0"></numIndex>
                                        <numIndex index="1"></numIndex>
                                    </numIndex>
                                </items>
                            </config>
                        </TCEforms>
                    </settings.templateLayout>
                </el>
            </ROOT>
        </template>
    </sheets>
</T3DataStructure>