grav-plugin-form
grav-plugin-form copied to clipboard
Print Twig in form field
Hi,
is it possible to print twig variable (something like page.header.title) inside a form field ?
for example :
---
title: A Page with an Example Form
form:
name: contact-form
fields:
- name: name
label: Name
placeholder: {{ page.header.title }}
autofocus: on
autocomplete: on
type: text
validate:
required: true
buttons:
- type: submit
value: Submit
- type: reset
value: Reset
---
Take a look at Using Function Calls (data-*@)in the Grav documentation. I've never used this method with the placeholder
field property but in theory it should work as it works with the label
property.
There's also a plugin which might help, see Form Prefiller Plugin.