【问题标题】:Switch label and input in TYPO3 7.6 form在 TYPO3 7.6 表单中切换标签和输入
【发布时间】:2016-05-16 15:32:05
【问题描述】:

在 TYPO3 7.4 中,可以在表单中切换标签和输入。由于某种原因,这已在 7.5 和 7.6 中进行了更改。

class = form
enctype = multipart/form-data
id = contact
method = post
layout {
            checkbox (
                    <input />
                    <label />
            )
}
prefix = tx_form
confirmation = 0

这是一个已知的错误还是有新的方法可以做到这一点?

非常感谢任何帮助。

【问题讨论】:

    标签: typo3 typoscript typo3-7.x typo3-7.6.x


    【解决方案1】:

    EXT:form 在 7.5 中被完全重写。整个前端渲染换成了extbase和fluid。

    很遗憾,尚未记录所有更改。几周前,我对可在此处找到的文档进行了重大清理:https://docs.typo3.org/typo3cms/extensions/form/layout section 对您来说更有趣。链接文档将说明如何设置视图特定布局。

    但是在 TYPO3 7.6 中自定义布局时,通过 TypoScript 使用 .layout 已经不是最好的方法了。正如changelog 所示,您应该使用流体。以下示例描述了具有一些新功能的表单。我正在全局设置一个额外的部分路径。但也可以为特定的表单元素设置部分路径(参见元素“900”)。

    plugin.tx_form {
        view {
            # set up additional partial path
            partialRootPaths.20 = EXT:generic_lib/Resources/Private/Extensions/Form/Partials/
        }
    }
    
    # build contact form
    lib.default_contact_form = FORM
    lib.default_contact_form {
        prefix = {$content.mailform.prefix}
        confirmation = 1
        # want to work on a clean base without .layout settings
        compatibilityMode = 0
    
        postProcessor {
            1 = mail
            1 {
                recipientEmail = {$content.mailform.recipientEmail}
    
                senderNameField = name
                senderEmailField = email
    
                ccEmail = TEXT
                ccEmail {
                    # depends on the fact that email is required and tested
                    data = GP:tx_form_form|{$content.mailform.prefix}|email
                    htmlSpecialChars = 1
                }
    
                subject = TEXT
                subject {
                    value = [{$website.title}] - Kontakt
                    lang.en = [{$website.title}] - Contact
                    lang.es = [{$website.title}] - Contacto
                    lang.it = [{$website.title}] - Contatto
                }
            }
    
            2 = redirect
            2.destination = {$content.mailform.redirectPage}
        }
    
        10 = TEXTLINE
        10 {
            name = name
            required = required
            type = text
            label.data = LLL:EXT:my_ext/Resources/Private/Language/Form/locallang.xlf:name
            placeholder.data = LLL:EXT:my_ext/Resources/Private/Language/Form/locallang.xlf:name
        }
    
        20 = TEXTLINE
        20 {
            name = email
            type = email
            required = required
            label.data = LLL:EXT:my_ext/Resources/Private/Language/Form/locallang.xlf:email
            placeholder.data = LLL:EXT:my_ext/Resources/Private/Language/Form/locallang.xlf:email
        }
    
        30 = TEXTAREA
        30 {
            name = message
            cols = 40
            rows = 5
            required = required
            data-foo = bar
            label.data = LLL:EXT:my_ext/Resources/Private/Language/Form/locallang.xlf:message
            placeholder.data = LLL:EXT:my_ext/Resources/Private/Language/Form/locallang.xlf:message
        }
    
        900 = TEXTLINE
        900 {
            name = honeypot
            type = text
            label.data = LLL:EXT:my_ext/Resources/Private/Language/Form/locallang.xlf:spam
            placeholder.data = LLL:EXT:my_ext/Resources/Private/Language/Form/locallang.xlf:spam
            autocomplete = off
            partialPath = FlatElements/Honeypot
            # hide field in confirmation and mail views
            visibleInConfirmationAction = 0
            visibleInMail = 0
        }
    
        1000 = SUBMIT
        1000 {
            name = submit
            value.data = LLL:EXT:my_ext/Resources/Private/Language/Form/locallang.xlf:submit
            class = button
        }
    
        rules {
            1 = required
            1 {
                element = name
                message.data = LLL:EXT:my_ext/Resources/Private/Language/Form/locallang.xlf:required
                error.data = LLL:EXT:my_ext/Resources/Private/Language/Form/locallang.xlf:mandatory
            }
    
            2 = email
            2 {
                element = email
                message = (max.muster@domain.com)
                error.data = LLL:EXT:my_ext/Resources/Private/Language/Form/locallang.xlf:mandatory_email
            }
        }
    }
    

    如果您需要任何进一步的帮助,您可以加入typo3.slack.com 并打开 ext-form 频道。在那里,您会找到更多示例和即时帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-29
      • 2019-11-07
      • 2017-11-15
      • 2020-02-06
      • 2015-05-14
      • 2015-07-12
      • 2020-01-26
      • 1970-01-01
      相关资源
      最近更新 更多