php - 如何创建没有相应页面的重力表单

标签 php html forms grav

我的页脚中有一个联系表,它将显示在所有页面上。我怎么做?文档认为我总是有一个特定的页面负责表单。 表格目前在 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/

相关文章:

javascript - 如果单击模态窗口提交按钮,则自动勾选复选框

php - 对月份进行排序,使它们连续排列

php - 使用 paypal 沙箱 ipn 模拟器时调试 ipn.php

php - 当我尝试以编程方式将图表添加到 google 电子表格时,api v4 失败并出现关于网格 id 的 Google_Service_Exception

html - 实现 css hover 以适用于所有 <a> 元素,其他元素之一

javascript - 在新窗口中打开链接或如果已打开则将焦点移至该链接

python - 如何从 Python 中的流(不是磁盘支持的文件)中读取 Excel 文件?

PHP 提交按钮不起作用。

c# - 我可以用这样的中断标记安全地替换新行吗?

php - Codeigniter 表单提交但没有使用我的模型进行数据库查询