Adding flexforms to plugins in newer versions of TYPO3
To add a flexform to your plugin, in addition to creating the flexform, you also need to add a couple lines to ext_tables.php
to make TYPO3 aware of your plugin. If you used the extbase_kickstarter to kickstart your extension, some boiler plate code has already been added to ext_localconf.php
and all you have to do is uncomment them, clear cache and reload:
$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY . '_pi1'] = 'pi_flexform';
t3lib_extMgm::addPiFlexFormValue($_EXTKEY . '_pi1', 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/flexform_pi1.xml');
If your extension key has an underscore in the name, however, you will find that you still see no flexform. This is because in some places in these lines the plugin signature (ex: cmgnews_pi1) is needed, instead of the extension key (ex: cmg_news). Conveniently, the blog_example
provides an example of how to do this:
$extensionName = t3lib_div::underscoredToUpperCamelCase($_EXTKEY);
$pluginSignature = strtolower($extensionName) . '_pi1';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
t3lib_extMgm::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/flexform_pi1.xml');
So that's it. Clear cache, reload the plugin, and you should now have a flexform :)
References: