typo3flexform

a few fields lack by adding a custom Flexform in TYPO3


I want to add a Flexform in my custom content element in TYPO3.

The fields I need are these: enter image description here

These fields are of bootstrap_package and I want to add exact the same fields like in bootstrap_package. But now my fields look like this: enter image description here

I show my code:

in tx_carousel_klassenfahrt_content_element.php

$GLOBALS['TCA']['tt_content']['types']['carousel_klassenfahrt'] = array_replace_recursive(
    $GLOBALS['TCA']['tt_content']['types']['carousel_klassenfahrt'],
    [
        'showitem' => '
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.headers;headers,
                tx_carousel_klassenfahrt_item,
            --div--;Options,
                pi_flexform;Advanced,
            --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.frames;frames,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.appearanceLinks;appearanceLinks,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
                --palette--;;language,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
                --palette--;;hidden,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,
                categories,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,
                rowDescription,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,
        '
    ]
);

// Add flexForms for content element configuration
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
    '*',
    'FILE:EXT:myextensionkey/Configuration/FlexForms/Klassenfahrt.xml',
    'Klassenfahrt'
);

in Klassenfahrt.xml

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
    <meta>
        <langDisable>1</langDisable>
    </meta>
    <sheets>
        <sDEF>
            <ROOT>
                <TCEforms>
                    <sheetTitle>Settings</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>
                    <interval>
                        <TCEforms>
                            <label>Interval in ms</label>
                            <config>
                                <type>input</type>
                                <size>8</size>
                                <default>5000</default>
                                <eval>required,int</eval>
                            </config>
                        </TCEforms>
                    </interval>
                    <transition>
                        <TCEforms>
                            <label>Transition</label>
                            <config>
                                <type>select</type>
                                <renderType>selectSingle</renderType>
                                <default>fade</default>
                                <items type="array">
                                    <numIndex index="0" type="array">
                                        <numIndex index="0">Fade</numIndex>
                                        <numIndex index="1">fade</numIndex>
                                    </numIndex>
                                    <numIndex index="1" type="array">
                                        <numIndex index="0">Slide</numIndex>
                                        <numIndex index="1">slide</numIndex>
                                    </numIndex>
                                </items>
                            </config>
                        </TCEforms>
                    </transition>
                    <wrap>
                        <TCEforms>
                            <label>LLL:EXT:Wrap</label>
                            <config>
                                <type>check</type>
                                <default>1</default>
                                <items type="array">
                                    <numIndex index="0" type="array">
                                        <numIndex index="0">Start the Carousel from the beginning once it has arrived at the end.</numIndex>
                                    </numIndex>
                                </items>
                            </config>
                        </TCEforms>
                    </wrap>
                    <show_nav_title>
                        <TCEforms>
                            <label>Show Navigation Title</label>
                            <config>
                                <type>check</type>
                                <default>0</default>
                                <items type="array">
                                    <numIndex index="0" type="array">
                                        <numIndex index="0">Show the navigation title of the records instead of the bubbles.</numIndex>
                                    </numIndex>
                                </items>
                            </config>
                        </TCEforms>
                    </show_nav_title>
                </el>
            </ROOT>
        </sDEF>
    </sheets>
</T3DataStructure>

in tt_content.php

$pluginSignature = str_replace('_', '', 'myextensionkey') . '_pi1';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
    $pluginSignature,
    // Flexform configuration schema file
    'FILE:EXT:myextensionkey/Configuration/FlexForms/Klassenfahrt.xml'
);

What should I write code more?

Also, if I write these below code in Typoscript, the frontend display an error Oops, an error occurred! Code: 202206171326512224c926.

dataProcessing.10 = RASANIDESIGN\KlassenFahrt\DataProcessing\FlexFormProcessor

I hope someone can help me. Thank you.


Solution

  • The fields you want to add are shown on this page and the usage with FlexForms is explained there: https://docs.typo3.org/m/typo3/reference-coreapi/11.5/en-us/ApiOverview/FlexForms/Index.html?highlight=flexform

    You've to decide where you want to add the flexForm. Likely you want to add it in tt_content only but not in your own table. If that's correct, then remove the last 6 lines from tx_carousel_klassenfahrt_content_element.php. Both options are shown in the documentation but as alternatives with the requirement to chose.

    The error is likely stating that the table tx_carousel_klassenfahrt_content_element never has a field pi_flexform, which should stay like that, as you can add there all required fields directly. Using FlexForms in the table tt_content for configuration is common practice to limit the amount of fields even if many extensions are installed.

    Concerning the array $GLOBALS['TCA']['tt_content']['types']['carousel_klassenfahrt'] it doesn't make sense to note it in the file tx_carousel_klassenfahrt_content_element.php because it's related to the table tt_content and should therefore be moved into tt_content.php. So actually the file tx_carousel_klassenfahrt_content_element.php needs some other content (any field definitions for the table), the content you listed should completely be removed probably.