小编Mar*_*son的帖子

将 Bootstrap 模态按钮映射到 Flask WTF 提交

我在 Flask Web 应用程序中呈现了一个表单。对于我的特定用例,我想添加一个模态对话框窗口来“确认”用户的选择。我可以显示模态,但我不知道如何将“确认”按钮(在模态中)映射到表单操作。bootstrap 文档中的示例不包括示例中的按钮映射。

{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
<unrelated content>
...
</unrelated content>
...
<h4>Enter the email address of the employee receiving the unit</h4>
<div class="col-lg-3">
    <div class="row">
        <form class="form" id="emailForm" action="{{  url_for('main.transfer', serial=system.serial)  }}" method="POST">
            {{  mail_form.hidden_tag()  }}
            {{  mail_form.email  }}
            {{  mail_form.submit  }}<!-- ###THIS IS WHAT I WANT THE MODAL CONFIRM TO TRIGGER -->
            <!-- Button trigger modal -->
            <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
            Transfer
            </button>
        </form>
    </div>
</div>

<!-- …
Run Code Online (Sandbox Code Playgroud)

flask flask-wtforms bootstrap-modal bootstrap-4

5
推荐指数
1
解决办法
2340
查看次数