typo3 - 以TYPO3 7.6形式切换标签和输入

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

在 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

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

非常感谢任何帮助。

最佳答案

EXT:表单在 7.5 中被完全重写。整个前端渲染被extbase和fluid取代。

不幸的是,尚未记录所有更改。几周前,我对文档进行了一次重大清理,可以在这里找到:https://docs.typo3.org/typo3cms/extensions/form/layout section对你来说更有趣。链接的文档将解释如何设置 View 特定布局。

但是,当涉及到 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 = (<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b7dad6cf99dac2c4c3d2c5f7d3d8dad6ded999d4d8da" rel="noreferrer noopener nofollow">[email protected]</a>)
            error.data = LLL:EXT:my_ext/Resources/Private/Language/Form/locallang.xlf:mandatory_email
        }
    }
}

您可以加入typo3.slack.com如果您需要任何进一步的帮助,请打开分机表单 channel 。在那里,您会找到更多示例和即时帮助。

关于typo3 - 以TYPO3 7.6形式切换标签和输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35244768/

相关文章:

mysql - 如何优化我的 MySQL 服务器?

javascript - includeJSFooter 和在模板中实现 JS 有什么区别? (打字3)

typo3 - 如何在typo3 7 TCA 中添加自定义向导?

typo3 - 在自定义模板中使用 EXT :recaptcha and EXT:form in Typo3 8. 7.9 获取错误消息

typo3 - 限制TYPO3后端布局中列中内容元素的数量

mysql - 添加通用标记到 tt_news - 数据库相关

TYPO3 文件为 .txt 还是 .ts?

javascript - 如何在自己的 Typo3 6.2 扩展中包含 .js 文件?

css - Typo3 7.6 向 RTE 中的 Heading-Element 添加自定义类