Using FlexForm when creating new content cType in TYPO3 plugins

1k views Asked by At

I'm adding new content types to my TYPO3 and I want to use FlexForms to define each content type options form.

I have followed this example: https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/latest/AddingYourOwnContentElements/

And modified it to use FlexForms from this example: https://wiki.typo3.org/Extension_Development,_using_Flexforms

But I believe I don't quite understand the settings in Configuration/TCA/Overrrides/tt_contant.php:

// Adds content new content elements
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
    [
        'LLL:EXT:lu_content/Resources/Private/Language/locallang.xlf:contacts.title',
        'lu_content__contacts',
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('lu_content').'Resources/Public/Icons/Contacts.svg',
    ],
    'CType',
    'lu_content'
);

$GLOBALS['TCA']['tt_content']['types']['lu_content__contacts']['showitem']                       = 'CType;;;1-1-1,pi_flexform;;;1-1-1';
$GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds'][',lu_content__contacts'] = 'FILE:EXT:lu_content/Configuration/FlexForms/Contacts.xml';

The form works, but looks like this: enter image description here

How do I get the form not to fall under Plugin Options?

And how do I make the title/header to be used in to list view? Currently i get [notitle] after save in the content list.

enter image description here

Thank you in advance.

PS: I'm currently developing on TYPO3 v7 but with support for v8.

1

There are 1 answers

0
David On BEST ANSWER

The Text for the tab as well as the arrangement of any tabs and fields is defined for general plugins in

$GLOBALS['TCA']['tt_content']['types']['list']

If you have defined an own CType it's quite probable that you wish to define own fields, palettes and types, hide standard-fields and perhaps replace default labels. The whole configuration for tt_content is quite complicated as it is used for all different content-elements and it can be seen in backend below System -> Configuration -> GLOBALS[TCA]:

enter image description here

The simplest option is to replace the label for the tab in $GLOBALS['TCA']['tt_content']['types']['list'].
Before / Default:

--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,--palette--;;general,--palette--;;headers,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.plugin,list_type;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:list_type_formlabel,pages;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:pages.ALT.list_formlabel,recursive,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,--palette--;;frames,--palette--;;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--;;access,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,--div--;LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_category.tabs.category,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

After / location to fill with own label: (look for ###YOUR_LABEL###):

--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,--palette--;;general,--palette--;;headers,--div--;###YOUR_LABEL###,list_type;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:list_type_formlabel,pages;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:pages.ALT.list_formlabel,recursive,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,--palette--;;frames,--palette--;;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--;;access,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,--div--;LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_category.tabs.category,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

and a more difficult approach would be to define an own type in $GLOBALS['TCA']['tt_content']['types'].

Here you find The documentation about TCA.

For your case are especially interesting the following chapters:

But if you want to change labels or other configuration of single fields you'd had to refer to the chapter / configuration about columns.
In the area ctrl you still can define some general options like sorting-fields or the behavior when the whole element is copied, have a look in that chapter to get an impression about all options. Also the desired and default label and value-field is configured there with

$GLOBALS['TCA']['tt_content']['ctrl']['label']

its also possible to combine two or more fields for the default display:

$GLOBALS['TCA']['tt_content']['ctrl']['label'] = 'header';
$GLOBALS['TCA']['tt_content']['ctrl']['label_alt'] = 'subheader';

you might still want to add the option

$GLOBALS['TCA']['tt_content']['ctrl']['label_alt_force'] = 1;

Configuring the form for a plugin can take quite some time even to understand all the options, but in general there are very much options to individualize it related to many needs. It's even possible to define user-functions to handle and display own options in the form which are not covered by the existing options.