【发布时间】:2021-04-16 15:36:05
【问题描述】:
有人可以解释这里发生了什么吗?我不明白为什么我在标签输入字段中提交的值没有与表单一起提交。我用both examples 试过这个 并且两者都不会正确发送值。
我正在使用bootstrap4-tagsinput
HTML 代码:
<form class="needs-validation" action="/archive" enctype="multipart/form-data" method="POST">
<div class="form-group">
<label>Solution Name</label>
<input name="solution_name" type="text" class="form-control" required>
<label>Vendor Name</label>
<input name="vendor_name" type="text" class="form-control" required>
</div>
<div class="form-group">
<label>Attachment</label>
<input name="file" type="file" class="form-control-file" required>
</div>
<div class="form-group">
<label>Tags</label>
<input class="form-select" name="tags" data-role="tagsinput">
</input>
</div>
<button type="submit" value="upload" class="btn btn-primary">Submit</button>
</form>
服务器
@review_archive_host.route('/archive', methods=["GET", "POST"])
@login_required
def archives():
if "review_archive" not in session['u']['flags']:
flash("You do not have permissions to access that feature/page")
return redirect(get_redirect_url())
#archive search page
if request.method == "POST":
#create a new archive record
d = request.form.to_dict(flat=True) or {}
return d
示例表单和响应:
回复:
{
"solution_name": "asdfs",
"tags": "",
"vendor_name": "asfsd"
}
【问题讨论】:
-
我根据这个插件更新了我的答案。
标签: python html flask bootstrap-4 bootstrap-tags-input