问:是否存在将CSS类分配给表单元素的默认方法?
我正在使用TYPO3 9.5.5和PHP 7.2。
到目前为止,我有办法,但是它是一个替代方法,然后是一个干净的解决方案。
form.ts
plugin.tx_form.settings.yamlConfigurations {
100 = EXT:skeleton/Configuration/YAML/CustomFormSetup.yaml
}
module.tx_form.settings.yamlConfigurations {
100 = EXT:skeleton/Configuration/YAML/CustomFormSetup.yaml
}
CustomFormSetup.yaml
TYPO3:
CMS:
Form:
persistenceManager:
allowedExtensionPaths:
20: EXT:skeleton/Resources/Private/Forms/
allowSaveToExtensionPaths: true
allowDeleteFromExtensionPaths: true
prototypes:
contactPrototype:
__inheritances:
10: TYPO3.CMS.Form.prototypes.standard
formElementsDefinition:
Form:
renderingOptions:
formClass: 'js-form'
templateRootPaths:
100: 'EXT:skeleton/Resources/Private/Forms/Templates/'
partialRootPaths:
100: 'EXT:skeleton/Resources/Private/Forms/Partials/'
layoutRootPaths:
100: 'EXT:skeleton/Resources/Private/Forms/Layouts/'
注意:我在TYPO3.CMS.Form.prototypes.contactPrototype.formElementsDefinition.Form.renderingOptions.formClass
Form.html
在这里,我只是从表单扩展名中复制了默认的Form.html并将class="{form.renderingOptions.formClass}"
添加到了formvh:form
标签中。
这可行,但仍然看起来很脏,因为我想要一种默认的添加类的方法