I'm trying to make a simple search form to filter my list of resources. I've made a form like this, but it's not placing q
in the url as a query param like I would expect with method: :get
<%= form_for @conn, post_path(@conn, :index), [as: :search, method: :get], fn f -> %>
<%= text_input f, :q, placeholder: "Search by title, content, etc." %>
<% end %>
When I submit this form with "term" as the search term, it results in search%5Bq%5D=term
being placed in the url (the url encoded version of the name of the q
field.) I expected just q=term
. Am I incorrect in expecting that? What's the proper way to do a simple search form?
text_input
name attribute set it toq
– NoDisplayName