Reputation: 13005
I am trying to assign a form-inline class to the following form in rails
<div class="row">
<div class="span6 offset3">
<%= form_for @annual do |f| class="form-inline" %>
<%= render 'shared/error_messages', :object => f.object %>
<%= f.label :a %>
<%= f.text_field :a class="input-small" placeholder="a" %>
<%= f.label :b %>
<%= f.text_field :b class="input-small" placeholder="b" %>
.
.
.
The bootstrap documentation for inline forms is here: http://twitter.github.com/bootstrap/base-css.html?#forms
When I try the above approach for the classes and placeholders, I get an error. What is the correct way to do this in rails?
Upvotes: 2
Views: 4441
Reputation: 966
In case this helps someone, I had to do :html => {:class -> "form-inline"}
for it to add the css class in Rails 4.
Upvotes: 7
Reputation: 13005
I found the solution via google, for those interested it is:
<div class="row">
<div class="span6 offset3">
<%= form_for @annual, {:class => "form-inline"} do |f| %>
<%= render 'shared/error_messages', :object => f.object %>
<%= f.text_field :a, :class=> "input-small", :placeholder=>"a" %>
<%= f.text_field :b, :class=> "input-small", :placeholder=>"b" %>
Upvotes: 5