我刚刚开始使用 Grav,我正在尝试创建一个表单。我遇到的问题是创建的文件不显示表单值。
这是我的表单的代码:
title: Report an issue
form:
name: report-issue
fields:
employee-id:
label: Id
autofocus: on
autocomplete: on
type: text
validate:
required: true
employee-name:
label: Name
autofocus: on
autocomplete: on
type: text
validate:
required: true
more-info:
label: Information
placeholder: Add any relevant information
style: vertical
type: textarea
validate:
required: false
buttons:
submit:
type: submit
value: Submit
reset:
type: reset
value: Reset
process:
- message: Thank you for your feedback!
- reset: true
- save:
fileprefix: contact-
dateformat: Ymd-His-u
extension: txt
operation: create
body: "{% include 'forms/data.txt.twig' %}"
我玩了一下树枝文件。这就是目前的样子:
{% for field in form.fields %}
<div><strong>{{ field.label }}</strong>: {{ string(field.value(field.name)|e) }}</div>
{% endfor %}
我遇到的问题是它只保存标签,但不保存输入的值。
例如,这是我提交答案后得到的结果。
<div><strong>Id</strong>: </div>
<div><strong>Name</strong>: </div>
<div><strong>Information</strong>: </div>
您正在“重置”表单数据,然后再保存...
尝试:
process:
- message: Thank you for your feedback!
- save:
fileprefix: contact-
dateformat: Ymd-His-u
extension: txt
operation: create
body: "{% include 'forms/data.txt.twig' %}"
- reset: true