Last active
February 13, 2024 19:45
-
-
Save georgringer/495f36ccfebd0e413cced4c1308561c5 to your computer and use it in GitHub Desktop.
Add fields to ext:news v11 flexform with TYPO3 v12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace Vendor\Extension\EventListener; | |
use TYPO3\CMS\Core\Configuration\Event\AfterFlexFormDataStructureParsedEvent; | |
class AfterFlexFormDataStructureParsedEventListener | |
{ | |
public function __invoke(AfterFlexFormDataStructureParsedEvent $event) | |
{ | |
$dataStructure = $event->getDataStructure(); | |
$identifier = $event->getIdentifier(); | |
// key could be e.g. "*,news_newssearchform" | |
if ($identifier['type'] === 'tca' && $identifier['tableName'] === 'tt_content' && str_starts_with($identifier['dataStructureKey'], '*,news_')) { | |
// instead of "inline", you could also use GeneralUtility::xml2array(file_get_contents(ExtensionManagementUtility::extPath('extension') . 'Configuration/FlexForms/Custom.xml')); | |
$dataStructure['sheets']['additional'] = [ | |
'ROOT' => [ | |
'sheetTitle' => 'My custom', | |
'type' => 'array', | |
'el' => [ | |
'settings.fo' => [ | |
'label' => 'A label', | |
'config' => [ | |
'type' => 'check', | |
'default' => 0, | |
], | |
], | |
], | |
], | |
]; | |
} | |
$event->setDataStructure($dataStructure); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
_defaults: | |
autowire: true | |
autoconfigure: true | |
public: false | |
Vendor\Extension\: | |
resource: '../Classes/*' | |
Vendor\Extension\EventListener\AfterFlexFormDataStructureParsedEventListener: | |
tags: | |
- name: event.listener | |
identifier: 'extension-flexformhook' | |
event: TYPO3\CMS\Core\Configuration\Event\AfterFlexFormDataStructureParsedEvent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment