控制器中的Flex表单配置 - typo3

时间:2016-08-23 07:02:27

标签: typo3 typoscript extbase

我有一个typo3扩展名。我需要使用flex forms保存基本配置。所以我写了一个flex表单。但是无法在控制器中访问这些值。

我的代码如下:

ext_tables.php

$extensionName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($_EXTKEY);
$frontendpluginName = 'userform'; //Your Front-end Plugin Name
$pluginSignature = strtolower($extensionName) . '_'.strtolower($frontendpluginName);
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/user_flexform.xml');

user_flexform.xml

<T3DataStructure>
    <sheets>
        <sDEF>
            <ROOT>
                <TCEforms>
                    <sheetTitle>Data Table Config</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>

                   <switchableControllerActions>
                        <TCEforms>
                            <label>Phone Number Format</label>
                            <config>
                                <type >select</type>
                                <items name="settings.phone" type="array">
                                    <numIndex index="0" type="array">
                                           <numIndex index="0">US</numIndex>
                                           <numIndex index="1">(678) 567-1234</numIndex>
                                    </numIndex>
                                    <numIndex index="1" type="array">
                                        <numIndex index="0">India</numIndex>
                                        <numIndex index="1">+91 6789765434</numIndex>
                                    </numIndex>
                                </items>
                            </config>
                        </TCEforms>
                    </switchableControllerActions>
                </el>
            </ROOT>
        </sDEF>
    </sheets>
</T3DataStructure>

user_controller.php

$config = $this->settings;

1 个答案:

答案 0 :(得分:4)

switchableControllerActions用于选择操作。这不是常规设置。这些定义有点不同

<T3DataStructure>
    <sheets>
        <sDEF>
            <ROOT>
                <TCEforms>
                    <sheetTitle>Data Table Config</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>
                <switchableControllerActions>
                    <TCEforms>
                        <label>LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.mode</label>
                        <onChange>reload</onChange>
                        <config>
                            <type>select</type>
                            <items>
                                <numIndex index="1">
                                    <numIndex index="0">Company</numIndex>
                                    <numIndex index="1">Company->list;Company->show</numIndex>
                                </numIndex>
                                <numIndex index="2">
                                    <numIndex index="0">Product</numIndex>
                                    <numIndex index="1">Product->list;Product->show</numIndex>
                                </numIndex>
                            </items>
                        </config>
                    </TCEforms>
                </switchableControllerActions>   
                   <settings.phone>
                        <TCEforms>
                            <label>Phone Number Format</label>
                            <config>
                                <type >select</type>
                                <items>
                                    <numIndex index="0" type="array">
                                           <numIndex index="0">US</numIndex>
                                           <numIndex index="1">(678) 567-1234</numIndex>
                                    </numIndex>
                                    <numIndex index="1" type="array">
                                        <numIndex index="0">India</numIndex>
                                        <numIndex index="1">+91 6789765434</numIndex>
                                    </numIndex>
                                </items>
                            </config>
                        </TCEforms>
                    </settings.phone>
                </el>
            </ROOT>
        </sDEF>
    </sheets>
</T3DataStructure>

如果您不需要switchableControllerActions,请将其删除。

请注意,一旦使用这些保存flexform可能会产生副作用,因为即使您在flexforms中删除了这些副作用仍然存在。因此,最好删除插件并创建一个新插件!