button =附加为elasticsearch搜索表单中的最后一个参数(button= appended as last param in elasticsearch search form)

编程入门 行业动态 更新时间:2024-10-28 08:27:25
button =附加为elasticsearch搜索表单中的最后一个参数(button= appended as last param in elasticsearch search form)

我正在使用弹性搜索,并遇到了一个奇怪的问题。 我有一个表单供用户提交他们的搜索但由于某种原因,当用户输入他们的查询然后点击提交按钮时,最后一个参数是按钮=参见下面的内容:

http://lvh.me:3000/products?utf8=(checkmark)&q=tree&button=

这是表格。 不确定这是表单,轨道还是弹性搜索的问题。

section.search = form_tag main_app.products_path, method: :get = text_field_tag 'q', nil, placeholder: t(:search) = button_tag type: 'submit' = icon('fa fa-search')

(编辑)HTML:

<form action="/products" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="✓"> <input type="text" name="q" id="q" placeholder="Search"><button name="button" type="submit">

任何帮助感谢!

I'm using elasticsearch and have run into a weird issue. I have a form for users to submit their search but for some reason, when a user enters their query and then clicks on the submit button, the last parameter is button= See bellow:

http://lvh.me:3000/products?utf8=(checkmark)&q=tree&button=

Here is the form. Not sure if this is an issue with the form, rails, or elastic search.

section.search = form_tag main_app.products_path, method: :get = text_field_tag 'q', nil, placeholder: t(:search) = button_tag type: 'submit' = icon('fa fa-search')

(edit) HTML:

<form action="/products" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="✓"> <input type="text" name="q" id="q" placeholder="Search"><button name="button" type="submit">

Any help appreciated!

最满意答案

您的<button name="button" type="submit">没有任何value属性(即button_tag的默认输出),因此在提交表单时, button=会像表单的任何其他命名参数一样追加。 如果您不希望提交该参数,则应该在button_tag添加一个空名称,即

button_tag type: 'submit', name: ''

Your <button name="button" type="submit"> doesn't have any value attribute (i.e. the default output for button_tag), hence when the form is submitted, button= is appended like any other named parameter of your form. If you don't want that parameter to be submitted, you should probably add an empty name into button_tag, i.e.

button_tag type: 'submit', name: ''

更多推荐

本文发布于:2023-08-07 20:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465820.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加为   表单   参数   elasticsearch   button

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!