gpt4 book ai didi

ruby-on-rails - 停止 button_tag 类型 :submit from submitting an empty button parameter

转载 作者:行者123 更新时间:2023-12-03 15:19:11 24 4
gpt4 key购买 nike

当我提交以下表单时,get URI 显示一个空按钮参数...这不会造成任何伤害,但看起来很丑。

我怎样才能摆脱它?

谢谢

=simple_form_for :category,
url: new_category_path,
method: :get,
class: "navbar-form navbar-left" do |f|
.input-group
=f.search_field :search,
type: "search",
class: "form-control",
placeholder: "Search for a category!"
=f.hidden_field :parent_id, :value => @category.id
%span.input-group-btn
=button_tag type:'submit', class: "btn btn-search" do
%i.fa.fa-search

网址看起来像:

http://localhost:3000/categories/new?utf8=%E2%9C%93&category%5Bsearch%5D=test&category%5Bparent_id%5D=1&button=

最佳答案

:name 选项设置为 nil。这应该可以解决问题。

%span.input-group-btn
= button_tag type:'submit', class: "btn btn-search", name: nil do
%i.fa.fa-search

关于ruby-on-rails - 停止 button_tag 类型 :submit from submitting an empty button parameter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30381630/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com