扩展 Formhandler:数据库插入
Extension Formhandler: database insert
我在使用扩展 formhandler 将数据插入数据库时遇到问题。
这是我的 html 表格:
<!-- ###TEMPLATE_FORM1### begin -->
<form action="###REL_URL###" id="projektform" method="post" class="formhandler">
<dl>
<dt><label for="sender_name">Imię</label></dt>
<dd>
<input type="text" name="formhandler[sender_name]" id="sender_name"
value="###value_sender_name###" />
</dd>
<dt><label for="sender_email">E-mail</label></dt>
<dd>
<input type="text" name="formhandler[sender_email]" id="sender_email"
value="###value_sender_email###" />
</dd>
<dt><label for="message">Wiadomość</label></dt>
<dd>
<textarea name="formhandler[message]" id="message">###value_message###</textarea>
</dd>
</dl>
<input type="submit" value="Wyślij" ###submit_nextStep### />
</form>
<!-- ###TEMPLATE_FORM1### end -->
<!-- ###TEMPLATE_SUBMITTEDOK### begin -->
<p>The following message has been sent:</p>
<p>###value_message###</p>
<!-- ###TEMPLATE_SUBMITTEDOK### end -->
<!-- ###TEMPLATE_EMAIL_ADMIN_PLAIN### begin -->
The following contact form has been sent to you:
Sender: ###value_sender_name### ###value_sender_email###
Text:
###value_message###
<!-- ###TEMPLATE_EMAIL_ADMIN_PLAIN### end -->
这是我的表格打字错误:
plugin.Tx_Formhandler.settings {
debug = 1
templateFile = fileadmin/forms/contact-form/1-contactform.html
formValuesPrefix = formhandler
finishers {
1 {
class = Tx_Formhandler_Finisher_Mail
}
2 {
class = Tx_Formhandler_Finisher_SubmittedOK
config.returns = 1
}
3.class = Tx_Formhandler_Finisher_DB
3.config {
table = contact
fields {
sender_name.mapping = sender_name
sender_email.mapping = sender_email
message.mapping = message
}
}
}
}
通过表单提交的邮件已发送,但仍然无法插入数据库。
知道哪里出了问题吗?
Finisher_SubmittedOK
应始终用作最后一个终结器,因为它会停止执行后续的终结器。 documentation 还表明,此终结器应用作最后一个。
如下更改您的 TypoScript,表单值将保存到您的 table。
plugin.Tx_Formhandler.settings {
debug = 1
templateFile = fileadmin/1-contactform.html
formValuesPrefix = formhandler
finishers {
1 {
class = Tx_Formhandler_Finisher_Mail
}
2.class = Tx_Formhandler_Finisher_DB
2.config {
table = contact
fields {
sender_name.mapping = sender_name
}
}
3 {
class = Tx_Formhandler_Finisher_SubmittedOK
config.returns = 1
}
}
}
我在使用扩展 formhandler 将数据插入数据库时遇到问题。
这是我的 html 表格:
<!-- ###TEMPLATE_FORM1### begin -->
<form action="###REL_URL###" id="projektform" method="post" class="formhandler">
<dl>
<dt><label for="sender_name">Imię</label></dt>
<dd>
<input type="text" name="formhandler[sender_name]" id="sender_name"
value="###value_sender_name###" />
</dd>
<dt><label for="sender_email">E-mail</label></dt>
<dd>
<input type="text" name="formhandler[sender_email]" id="sender_email"
value="###value_sender_email###" />
</dd>
<dt><label for="message">Wiadomość</label></dt>
<dd>
<textarea name="formhandler[message]" id="message">###value_message###</textarea>
</dd>
</dl>
<input type="submit" value="Wyślij" ###submit_nextStep### />
</form>
<!-- ###TEMPLATE_FORM1### end -->
<!-- ###TEMPLATE_SUBMITTEDOK### begin -->
<p>The following message has been sent:</p>
<p>###value_message###</p>
<!-- ###TEMPLATE_SUBMITTEDOK### end -->
<!-- ###TEMPLATE_EMAIL_ADMIN_PLAIN### begin -->
The following contact form has been sent to you:
Sender: ###value_sender_name### ###value_sender_email###
Text:
###value_message###
<!-- ###TEMPLATE_EMAIL_ADMIN_PLAIN### end -->
这是我的表格打字错误:
plugin.Tx_Formhandler.settings {
debug = 1
templateFile = fileadmin/forms/contact-form/1-contactform.html
formValuesPrefix = formhandler
finishers {
1 {
class = Tx_Formhandler_Finisher_Mail
}
2 {
class = Tx_Formhandler_Finisher_SubmittedOK
config.returns = 1
}
3.class = Tx_Formhandler_Finisher_DB
3.config {
table = contact
fields {
sender_name.mapping = sender_name
sender_email.mapping = sender_email
message.mapping = message
}
}
}
}
通过表单提交的邮件已发送,但仍然无法插入数据库。 知道哪里出了问题吗?
Finisher_SubmittedOK
应始终用作最后一个终结器,因为它会停止执行后续的终结器。 documentation 还表明,此终结器应用作最后一个。
如下更改您的 TypoScript,表单值将保存到您的 table。
plugin.Tx_Formhandler.settings {
debug = 1
templateFile = fileadmin/1-contactform.html
formValuesPrefix = formhandler
finishers {
1 {
class = Tx_Formhandler_Finisher_Mail
}
2.class = Tx_Formhandler_Finisher_DB
2.config {
table = contact
fields {
sender_name.mapping = sender_name
}
}
3 {
class = Tx_Formhandler_Finisher_SubmittedOK
config.returns = 1
}
}
}