RailsCasts Pro episodes are now free!
Learn more or hide this
There is a newer version of this episode, see the revised episode.
Resources
bundle_install rails g simple_form:install
gem 'simple_form'
<%= simple_form_for @product do |f| %> <%= f.error_messages %> <%= f.input :name %> <%= f.input :price, :hint => "prices should be in USD" %> <%= f.input :released_on %> <%= f.association :category, :include_blank => false %> <%= f.input :rating, :collection => 1..5, :as => :radio %> <%= f.input :discontinued %> <%= f.button :submit %> <% end %>
.simple_form label { float: left; width: 100px; text-align: right; margin: 2px 10px; } .simple_form div.input { margin-bottom: 10px; } .simple_form div.boolean, .simple_form input[type='submit'] { margin-left: 120px; } .simple_form div.boolean label, .simple_form label.collection_radio { float: none; margin: 0; } .simple_form label.collection_radio { margin-right: 10px; margin-left: 2px; } .simple_form .error { clear: left; margin-left: 120px; font-size: 12px; color: #D00; display: block; } .simple_form .hint { clear: left; margin-left: 120px; font-size: 12px; color: #555; display: block; font-style: italic; }