views:

238

answers:

3

Is there a way to add styling to rails form_for and make it display inline?

+1  A: 

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| %>
Andy Gaskell
If there's a cleaner way, great ... but this works just fine for me if there isn't! Thanks so much Andy!
Daniel
A: 

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

application.css:
.inline form {display: inline; }

<div class=inline>
  <%= form....
</div>
dalyons
+1  A: 

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.

Christoph Schiessl