控制器中的 Flex 表单配置 - typo3
Flex form configuration in controller - typo3
我有一个错字3 extension.I 需要使用 flex forms.So 保存基本配置,我写了一个 flex form.But 无法在控制器中访问这些值。
我的代码如下
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;
switchableControllerActions
用于select一个动作。这不是常规设置。这些定义有点不同
<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 中删除了它们,它们仍然存在。因此最好是删除插件并创建一个新插件!
我有一个错字3 extension.I 需要使用 flex forms.So 保存基本配置,我写了一个 flex form.But 无法在控制器中访问这些值。
我的代码如下
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;
switchableControllerActions
用于select一个动作。这不是常规设置。这些定义有点不同
<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 中删除了它们,它们仍然存在。因此最好是删除插件并创建一个新插件!