是否可以使用 Grav CMS 在一个模块化页面中创建 2 个表单?
Is it possible to create 2 forms in one modular page using Grav CMS?
我是 Grav CMS 的新手。我在一个模块化页面中创建 2 个表单(联系表单和 application/register 表单)时遇到问题。可能吗?
您现在可以使用 Form 2.0 插件来完成!
这真的很简单,例如,如果您的模块页面上有两个模块,在您的情况下,联系表和注册表.
这意味着你有两个这样的 MarkDown 文件:
contact_form.md :
---
title: contact_form_modular
forms:
contact_form:
name: contact
action: /home
fields:
-
name: email
label: Email
validate:
required: true
buttons:
-
type: submit
value: Submit
process:
-
save:
fileprefix: register-
dateformat: Ymd-His-u
extension: txt
body: "{% include 'forms/data.txt.twig' %}"
operation: add
-
message: 'Thank for contacting us !'
---
## Modular title
Here a form to contact me
和register_form.md:
---
title: register_form_modular
forms:
register_form:
name: register
action: /home
fields:
-
name: email
label: Email
validate:
required: true
-
name: password
label: Password
validate:
required: true
buttons:
-
type: submit
value: Submit
process:
-
email:
from: "{{ config.plugins.email.from }}"
to: "{{ config.plugins.email.to }}"
subject: "Contact by {{ form.value.name|e }}"
body: "{% include 'forms/data.html.twig' %}"
-
save:
fileprefix: register-
dateformat: Ymd-His-u
extension: txt
body: "{% include 'forms/data.txt.twig' %}"
operation: add
-
message: 'Thank for registering'
---
## Modular title
Here is a form to register to my app !
然后在主题模板文件夹中的 contact_form.html.twig 文件中,放入以下行来呈现表单:
{% include "forms/form.html.twig" with {form: forms('contact_form')} %}
register_form.html.twig也是一样:
{% include "forms/form.html.twig" with {form: forms('register_form')} %}
当然,如果您愿意,可以制作自己的 form.html.twig 以便能够自定义表单的外观,将新文件放在主题模板文件夹中的表单文件夹中。
例如:template/forms/register_form_template.html.twig
而在你的 register_form.html.twig 中,你像这样更改:
{% include "forms/register_form_template.html.twig" with {form: forms('register_form')} %}
我希望我已经说清楚了,但如果这里 link 到文档 :
我是 Grav CMS 的新手。我在一个模块化页面中创建 2 个表单(联系表单和 application/register 表单)时遇到问题。可能吗?
您现在可以使用 Form 2.0 插件来完成!
这真的很简单,例如,如果您的模块页面上有两个模块,在您的情况下,联系表和注册表.
这意味着你有两个这样的 MarkDown 文件:
contact_form.md :
---
title: contact_form_modular
forms:
contact_form:
name: contact
action: /home
fields:
-
name: email
label: Email
validate:
required: true
buttons:
-
type: submit
value: Submit
process:
-
save:
fileprefix: register-
dateformat: Ymd-His-u
extension: txt
body: "{% include 'forms/data.txt.twig' %}"
operation: add
-
message: 'Thank for contacting us !'
---
## Modular title
Here a form to contact me
和register_form.md:
---
title: register_form_modular
forms:
register_form:
name: register
action: /home
fields:
-
name: email
label: Email
validate:
required: true
-
name: password
label: Password
validate:
required: true
buttons:
-
type: submit
value: Submit
process:
-
email:
from: "{{ config.plugins.email.from }}"
to: "{{ config.plugins.email.to }}"
subject: "Contact by {{ form.value.name|e }}"
body: "{% include 'forms/data.html.twig' %}"
-
save:
fileprefix: register-
dateformat: Ymd-His-u
extension: txt
body: "{% include 'forms/data.txt.twig' %}"
operation: add
-
message: 'Thank for registering'
---
## Modular title
Here is a form to register to my app !
然后在主题模板文件夹中的 contact_form.html.twig 文件中,放入以下行来呈现表单:
{% include "forms/form.html.twig" with {form: forms('contact_form')} %}
register_form.html.twig也是一样:
{% include "forms/form.html.twig" with {form: forms('register_form')} %}
当然,如果您愿意,可以制作自己的 form.html.twig 以便能够自定义表单的外观,将新文件放在主题模板文件夹中的表单文件夹中。
例如:template/forms/register_form_template.html.twig
而在你的 register_form.html.twig 中,你像这样更改:
{% include "forms/register_form_template.html.twig" with {form: forms('register_form')} %}
我希望我已经说清楚了,但如果这里 link 到文档 :