gpt4 book ai didi

gravity-forms-plugin - 是否可以使用 Grav CMS 在一个模块化页面中创建 2 个表单?

转载 作者:行者123 更新时间:2023-12-02 00:51:59 26 4
gpt4 key购买 nike

我是 Grav CMS 的新手。我在一个模块化页面中创建 2 个表格(联系表格和申请/注册表)时遇到问题。可能吗?

最佳答案

您现在可以使用 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')} %}

我希望我已经清楚了,但如果这里是文档的链接:

https://learn.getgrav.org/forms/forms#multiple-forms

关于gravity-forms-plugin - 是否可以使用 Grav CMS 在一个模块化页面中创建 2 个表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39009791/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com