0

I have the following search form I made:

          <%= bootstrap_form_for :search, url: admin_panel_users_path, method: 'get' do |f| %>
              <div class="row" style="margin-top: 15px; line-height: 25px;">
                <div class="col-md-2 text-center" style="margin-top: 6px; font-weight: bold">
                  <%= f.label :keyword%>
                </div>
                <div class="col-md-8">
                  <%= f.text_field :keyword, hide_label: true %>
                </div>
                <div class="col-md-2">
                  <%= f.submit 'Search User', hide_attribute_name: true, class: 'btn btn-success' %>
                </div>
              </div>
          <% end %>

However, when I submit, I get a lot of things that I don't need as parameters in my url, and the url then looks like this:

?utf8=✓&search%5Bkeyword%5D=&commit=Search+User

While I only want the url to be like this:

?keyword=mysearch

Is there a way to do it with the bootstrap gem? And in addition, remove that hidden UTF field it places

Ben Beri
  • 1,101
  • 4
  • 23
  • 64

1 Answers1

1

Pass enforce_utf8 with form as false. It was added in Rails 3 originally to fight IE compatibility issues for a form submitted with GET request. It is called as _snowman param.

:enforce_utf8 - If set to false, a hidden input with name utf8 is not output.

For removing commit parameter, pass submit_tag with name:nil

<%= f.submit 'Search User', name: nil, hide_attribute_name: true, class: 'btn btn-success' %>
kiddorails
  • 12,961
  • 2
  • 32
  • 41