Reputation: 115
I'm trying to style the following form with bootstrap:
<%= form_tag("/products", method: "get") do %>
<%= label_tag(:q, "Search for:", ) %>
<%= text_field_tag(:q) %>
<%= submit_tag("Search") %>
<% end %>
this code is being rendered like this:
<form action="/products" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="✓" />
<label for="q">Search for:</label>
<input type="text" name="q" id="q" />
<input type="submit" name="commit" value="Search" data-disable-with="Search" />
</form>
I would like to add classes to the tags form
and input
.
Many thanks in advance for your help.
Upvotes: 0
Views: 1091
Reputation: 81
You can do
<%= form_tag("/products", method: "get", class: 'attributes-goes-here') do %>
<%= label_tag(:q, "Search for:", ) %>
<%= text_field_tag(:q, nil, class: 'attributes-goes-here') %>
<%= submit_tag("Search") %>
<% end %>
Note the ', class: 'attributes-goes-here'
Upvotes: 0
Reputation: 1923
<%= form_tag("/products", method: "get", class: "someClass") do %>
<%= label_tag(:q, "Search for:", ) %>
<%= text_field_tag(:q, nil, class: 'anyclass') %>
<%= submit_tag("Search") %>
<% end %>
just replace someClass
and anyclass
with your choice
Upvotes: 1