我坚持使用formhandler在一个页面上创建多个表单。到目前为止我所做的是我的设置变量中的以下代码
plugin.Tx_Formhandler.settings {
debug = 0
formValuesPrefix = formhandler
singleErrorTemplate {
totalWrap = <div class="error">|</div>
singleWrap = <span class="message">|</span>
}
preProcessors {
1.class = Tx_Formhandler_PreProcessor_LoadDefaultValues
1 {
config.1 {
name.defaultValue = Name
email.defaultValue = E-Mail
}
}
}
validators {
1.class = Validator_Default
1.config.fieldConf {
name {
errorCheck.1 = required
}
email {
errorCheck.1 = required
errorCheck.2 = email
}
}
}
singleErrorTemplate {
totalWrap = <div class="error">|</div>
singleWrap = <span class="message">|</span>
}
finishers {
# Finisher_Mail sends emails to an admin and/or the user.
1.class = Finisher_Mail
# Finisher_Redirect will redirect the user to another page after the form was submitted successfully.
5.class = Finisher_Redirect
5.config {
redirectPage = {$formhandlerExamples.basic.contact-form.redirectPage}
}
}
}
但现在我想在我的网站上添加第二个表单。如果我只是添加第二个plugin.Tx_Formhandler.settings {}和一个新的formValuesPrefix它不起作用。我只得到一个&#34; Caught异常:找不到模板&#34;错误。
当我删除第一个表单和第一个设置时,我的表单正在运行。
我可以使用教程或其他方法来了解如何在一个页面上使用formhandler添加多个表单。
答案 0 :(得分:1)
我终于想通了。您需要做的是使用settings.predef而不是标准设置。例如
plugin.Tx_Formhandler.settings.predef.formhandler {
# This name appears in the dropdown selector in plugin record
name = Newsletter Contact
debug = 0
formValuesPrefix = formhandler
singleErrorTemplate {
totalWrap = <div class="error">|</div>
singleWrap = <span class="message">|</span>
}
validators {
1.class = Validator_Default
1.config.fieldConf {
name {
errorCheck.1 = required
}
email {
errorCheck.1 = required
errorCheck.2 = email
}
}
}
singleErrorTemplate {
totalWrap = <div class="error">|</div>
singleWrap = <span class="message">|</span>
}
finishers {
# Finisher_Mail sends emails to an admin and/or the user.
1.class = Finisher_Mail
# Finisher_Redirect will redirect the user to another page after the form was submitted successfully.
5.class = Finisher_Redirect
5.config {
redirectPage = 8
}
}
}
现在,您将在模块中的下拉列表中找到此设置。如果您创建了更多这些,您将有更多设置可供选择。每个Form都需要它自己的setting.predef。