Wordpress中的Bootstrap模态具有重力形式


Bootstrap Modal in Wordpress With Gravity Form

我在Wordpress网站上有一个页面,它有一个Bootstrap模态,当点击图形时会出现,模态中有一个Gravity Form。当第一次加载页面时,模态中的Gravity Form代码会导致我的一些导航链接无法工作。我很确定是php代码的组合调用了Gravity Form(通过调用它的短代码)和引导模式窗口,因为当我从模式中删除Gravity Form php代码或删除模式代码并在页面上显示表单时,导航链接可以正常工作。

你知道为什么在Bootstrap模式中使用Gravity Form会导致Wordpress导航不起作用吗?

这是带有代码的站点:http://www.stlmaa.com/

这是按钮的图形代码:

<img src="<?php bloginfo('template_directory'); ?>/images/questions.png" width="250px" data-toggle="modal" data-target="#myModal" style="cursor: pointer"/>

这是模式代码:

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel" style="color:black">Contact Us!</h4>
</div>
<div class="modal-body" style="color: black; padding-top:-20px">
<?php echo do_shortcode('[gravityform id=1 name=ContactUs title=false description=false]'); ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>

我不完全确定你所说的"导航问题"是什么意思。网站上的导航似乎一切都很好,所以我猜你已经解决了这个问题。

如果没有,并且您提到了提交时模态是如何关闭的,我建议您在短代码中添加一个额外的ajax属性,以便表单保持打开状态。这将确保您的用户知道所有适当的字段都已填写完毕,并向他们提供确认。您还需要删除"名称"字段;只要确保你在表格ID中有正确的数字。它应该是这样的:

<?php echo do_shortcode('[gravityform id="1" title="false" description="false" ajax="true"]'); ?>

来源:https://www.gravityhelp.com/documentation/article/embedding-a-form/

这能解决你的问题吗?

我知道这篇文章很旧,但它在谷歌中有索引,所以以防万一其他人在你的搜索中发现。。。。

您确实需要使用ajax,否则提交表单将关闭模态并将您重定向到新页面。

然而;阻止模态关闭更改不是通过嵌入短代码(事实上,你应该使用该函数,而不是@ahurleb发布的同一URL的短代码),而是通过引导选项值。您可以使表单持久化,并将另一个按钮设置为手动关闭或在模态边界外单击时关闭。

有关正确嵌入重力形式的函数,请参见此处:https://docs.gravityforms.com/adding-a-form-to-the-theme-file/

gravity_form( $id_or_title, $display_title = true, $display_description = true, $display_inactive = false, $field_values = null, $ajax = false, $tabindex, $echo = true );

要了解引导模式以及如何使其持久化,请参阅此处:防止表单提交时关闭引导模式窗口