rails form_for styling rails form_for styling ruby-on-rails ruby-on-rails

rails form_for styling


There might be a cleaner way to do this, but it works. (I tried with another nested hash, no dice)

 <% form_for(@model, :html => { :style => 'background-color:red;' }) do |f| %>


A even cleaner way would be to define the styling in an external stylesheet (like application.css). form_for creates a <form id="something"/> tag with an id attribute. You can of course use this id in your stylesheet(s) to apply some specific styling to the form.


Put it in a div of the appropriate class? Its a display thing, not a rails thing.

application.css:

.inline form { display: inline; }

form.html.erb

<div class="inline">  <%= form....</div>