[TYPO3-dev] TCEForms Backendmodul - generate form based on TCA definition and use data manually in controller
Robin Kemna
Kemna.Robin at gmail.com
Thu Nov 2 15:22:47 CET 2017
Envirement:
TYPO3: v.8.7.4
Webserver: Apache
PHP: 7.0.24
I intend to design a backendmodul where i can manage data saved behind a REST-API oder nativ Database (MariaDB).
Further it should be possible to restrict access to different form fields based on the TYPO3 authorization concept.
So i decided to use the already implemented functionality of TCA Form rendering which already includes the user-authorization concept as well as the generation of special form fields like date picker and so on.
Therefore i used the following functions..
$nodeFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(NodeFactory::class);
$formResultCompiler = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(FormResultCompiler::class);
$formDataGroup = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(TcaDatabaseRecord::class);
$formDataCompiler = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup);
$formDataCompilerInput = [
'tableName' => '{tabellen_name}',
'command' => $command,
];
$formData = $formDataCompiler->compile($formDataCompilerInput);
$formData['renderType'] = 'outerWrapContainer';
$formResult = $nodeFactory->create($formData)->render();
$formResultCompiler->mergeResult($formResult);
$this->view->assign('form',$formResult);
The form is getting rendered quiet perfectly but the required JavaScript is not.
The documentation said that it should be delivered in the upper functions calls aswell.. but nothing.
When i try to send the form, no data is send to the action, because all name attributes are not set properly.
Data-name Attributes are set instead. Those should be converted to name attributes by the missing JavaScript.
So i looked it up in other extensions and saw that the TYPO3/CMS/Backend/FormEngine AMD is needed.
When using the AMD it ends up in following error.. logged in the consol
Fehlermeldung: "Cannot read property 'formName' of undefined" (line 3)
1: var FormEngine = {
2: Validation: FormEngineValidation,
3: formName: TYPO3.settings.FormEngine.formName,
4: openedPopupWindow: null,
5: legacyFieldChangedCb: function() { !$.isFunction(TYPO3.settings.FormEngine.legacyFieldChangedCb) ||
6: TYPO3.settings.FormEngine.legacyFieldChangedCb(); },
7: browserUrl: ''
8: };
Does anybody got experience in this topic?
You need more information, ask me!
More information about the TYPO3-dev
mailing list