TYPO3 8.7.17 ext:form-如何重用舞台/字段集?

时间:2018-07-30 14:39:48

标签: forms typo3 typo3-8.x typo3-extensions

所有人!

我正在使用扩展名 form ,我想创建自定义表单元素。

我需要从定义的字段列表中创建多行...类似这样的东西:

Example of the custom form element I want.

为了创建自定义表单元素,我遵循了tutorial written by Manuel Selback。我想我可以重用FieldSet元素。问题是我的新项目在后端表单编辑器中不能很好地显示(字段名称和类型未显示)。

Custom field

这是我的代码:

// EXT:my_ext/Configuration/Yaml/BaseSetup.yaml
TYPO3:
  CMS:
    Form:
      prototypes:
        standard:
          formEditor:
            formEditorPartials:
              FormElement-FieldRow: 'Stage/SimpleTemplate'

          formElementsDefinition:
            Form:
              renderingOptions:
                templateRootPaths:
                  100: 'EXT:my_ext/Resources/Private/ext/form/Frontend/Templates/'
                partialRootPaths:
                  100: 'EXT:my_ext/Resources/Private/ext/form/Frontend/Partials/'
                layoutRootPaths:
                  100: 'EXT:my_ext/Resources/Private/ext/form/Frontend/Layouts/'
            FieldRow:
              __inheritances:
                10: 'TYPO3.CMS.Form.prototypes.standard.formElementsDefinition.Fieldset'


// EXT:my_ext/Configuration/Yaml/FormEditorSetup.yaml
TYPO3:
  CMS:
    Form:
      prototypes:
        standard:
          formEditor:
            dynamicRequireJsModules:
              additionalViewModelModules:

            formEditorPartials:
              FormElement-FieldRow: 'Stage/SimpleTemplate'

          formElementsDefinition:
            FieldRow:
              formEditor:
                label: 'formEditor.elements.FieldRow.label'
                group: container
                _isCompositeFormElement: true
                groupSorting: 1000
                iconIdentifier: 't3-form-icon-fieldrow'
                editors:
                  200:
                    label: 'formEditor.elements.FieldRow.editor.label.label'
                  230: null
                  800: null

我想念什么吗?

非常感谢您。

1 个答案:

答案 0 :(得分:0)

要解决显示名称和字段类型的问题,我通过添加视图模型(TYPO3.CMS.Form.prototypes.standard.formEditor.dynamicRequireJsModules.additionalViewModelModules)编辑了EXT:my_ext / Configuration / Yaml / FormEditorSetup.yaml :

// EXT:my_ext/Configuration/Yaml/FormEditorSetup.yaml
TYPO3:
  CMS:
    Form:
      prototypes:
        standard:
          formEditor:
            dynamicRequireJsModules:
              additionalViewModelModules:
                - 'TYPO3/CMS/UnalForm/Backend/FormEditor/FieldRowViewModel'

此后,我创建了JavaScript文件 Resources / Public / JavaScript / Backend / FormEditor / FieldRowElementViewModel.js ,以在舞台区域中正确显示我的自定义元素。