我正在使用弹性搜索,并遇到了一个奇怪的问题。 我有一个表单供用户提交他们的搜索但由于某种原因,当用户输入他们的查询然后点击提交按钮时,最后一个参数是按钮=参见下面的内容:
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: ''更多推荐
发布评论