FlexForms 2.0 aka Dot Forms
Have you ever dreamed of creating virtual form fields, known as Flex Forms in TYPO3 CMS, but without that awful XML and even more flexible? I definitely have, so I created an extension for this. It's called dot_forms and allows you to define TCA fields with dots in the field name, e.g. settings.pagination.itemsPerPage.
This way, you can define your fields as you usually do with pure TCA syntax. You just put at least one dot inside the field name. The fields are displayed just like any other field defined in TCA and you can place them in any tab or palette to allow for more flexibility compared to Flex Forms. Please see, the following example:
// Define the columns/fields
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', [
'settings.pagination.itemsPerPage' => [
'label' => 'Items per page',
'config' => [
'type' => 'number',
'format' => 'integer'
'size' => 5,
'default' => 10,
],
],
'settings.pagination.maxNumberOfLinks' => [
'label' => 'Max number of links',
'config' => [
'type' => 'number',
'format' => 'integer'
'size' => 5,
'default' => 7,
],
],
]);
// Create a custom palette
$GLOBALS['TCA']['tt_content']['palettes']['settings.pagination'] = [
'label' => 'Pagination',
'showitem' => 'settings.pagination.itemsPerPage, settings.pagination.maxNumberOfLinks',
];
// Add the fields to the record type(s)
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('tt_content', '--palette--;;settings.pagination', 'your_recordtype', 'after:header');
All fields starting with the same root or main field name (settings, in the example) are packed together as JSON and stored in a single database field, just like Flex Forms.
When using this with an Extbase plugin, you can use the provided ActionController to automatically merge the settings field into $this→settings inside your controller. There is also a DataProcessor to add all dotted fields to the available data in a FLUIDTEMPLATE.
You're welcome to try this extension and provide feedback. I'm happy to assist and improve the extension, if necessary.
Dette website bruger Disqus for at vise kommentarer. På grund af databeskyttelsesregler (GDPR) skal du godkende brugen af eksterne tjenester som Disqus.
Vis kommentarer