Ben Downey Ben Downey - 4 months ago 47
CSS Question

Rails: how to style submit tag with custom css

The code below creates a form and styles the "submit" button according to some css ("button"). The problem is, when the page renders, it shows the normal rails submit tag button on top of the customized "button" css. How do I mute or disable the visual aspects of the rails submit tag button while still making it submit the form?

=form_tag new_site_url, :method => :get do
=text_field_tag :homepage,'', type: "text", class: 'text'
%button
=submit_tag "GO!"

Answer

Could you do this :

=form_tag new_site_url, :method => :get do
  =text_field_tag :homepage,'', type: "text", class: 'text'
  =submit_tag "GO!", class: 'button'

and set the css style for the button?

It better to do this :

=form_tag new_site_url, :method => :get do |f|
  =f.text_field '', type: "text", class: 'text'
  =f.submit "GO!", class: 'button'