Reputation: 5552
I have seen examples like this:
<%= form_tag(products_path, :method => "get", id: "search-form") do %>
<%= text_field_tag :search, params[:search], placeholder: "Search products" %>
<%= submit_tag "Search", :name => nil %>
<% end %>
But if I replace the submit_tag with just some standard html, like this:
<%= text_field_tag ... same as above %>
<div class="input-group-btn">
<button class="btn btn-secondary">
<span class="glyphicon glyphicon-search"></span>
</button>
</div>
I can still submit the form using this button or pressing enter.
What then is the purpose of the submit_tag? Is it just a quick way to get a simple submit button (which obviously I didn't want, I wanted a magnifying glass button)
Upvotes: 0
Views: 794
Reputation:
The purpose of a submit_tag
is not only that it helps you write the HTML. It can be controlled directly by rails with access to @variables
and other server side dynamics.
Upvotes: 1