我的页脚中有一个联系表,它将显示在所有页面上。我怎么做?文档认为我总是有一个特定的页面负责表单。 表格目前在 Twig 中看起来像这样:
<form method='POST'>
<label for='name'>{{ "o.footer.form.name"|t }}</label>
<input type='text' id='name' name='name' required='required'/>
<label for='email'>{{ "o.footer.form.email"|t }}</label>
<input type='text' id='email' name='email'/>
<label for='phone'>{{ "o.footer.form.phone"|t }}</label>
<input type='tel' id='phone' name='phone'/>
<label for='message'>{{ "o.footer.form.message"|t }}</label>
<textarea id='message' name='message'></textarea>
<input type='submit' value="{{ "o.footer.form.submit"|t }}"/>
</form>
最佳答案
自 Form plugin 的最新版本以来,您可以这样做.
只需创建一个定义了表单的页面,然后从其他页面调用它,例如:
{% include "forms/form.html.twig" with {form: forms( {route: '/newsletter-signup'} ) } %}
更多信息:https://learn.getgrav.org/forms/forms#displaying-forms-in-page-content
关于php - 如何创建没有相应页面的重力表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46523601/