Rails 3 simple_form_for: defaults

I have a bunch of scores that I want to render horizontally using form-inline (twitter bootstrap). If they are specified separately, they work fine, but if specified using: by default, the class is not displayed.

%ul.nav.nav-tabs#tab
  %li= link_to "General", "#client_tab1", 'data-toggle'=>"tab"
  %li= link_to "Applications", "#client_tab2", 'data-toggle'=>"tab"
= simple_form_for @client, defaults:{input_html:{class:'form-inline'}}, :html=>{:class=>"client tab-content"} do |f|
  #client_tab1.tab-pane.fade.in.active
    = render :partial => "client", :locals => {:f => f}
  #client_tab2.tab-pane.fade.in
    = render :partial => "applications/applications", :locals => {:f => f}
  .actions
    = f.button :submit, class:"btn-primary", value: "Save"

and partial looks something like this:

.status
  .span3
    = f.label :status
    = f.collection_select :status_id, selection_list(Status), :last, :first
    %br
    = f.input :open_date, :as => :jdate
    %br
    = f.label :assigned_to
    = f.collection_select :assigned_to_id, selection_list(User), :last, :first
    %br
    .form-inline
      = f.label :assistant
      = f.collection_select :assistant_id, selection_list(User), :last, :first
    %br

In the above example with an explicit .form-inline, everything works as expected. But according to the sample code below https://github.com/plataformatec/simple_form the classes defined in: defaults should apply to all methods. This is actually not the case.

<%= simple_form_for @user, :defaults => { :input_html => { :class => 'default_class' } } do |f| %>
  <%= f.input :username, :input_html => { :class => 'special' } %>
  <%= f.input :password, :input_html => { :maxlength => 20 } %>
  <%= f.input :remember_me, :input_html => { :value => '1' } %>
  <%= f.button :submit %>
<% end %>

Can someone explain why this could be or what I am doing wrong?

+3
source share
1 answer

Few things:

  • twitter, , form-inline , , , , , div.

( ):

.form-search input,
.form-inline input,
.form-horizontal input,
.form-search textarea,
.form-inline textarea,
.form-horizontal textarea,
.form-search select,
.form-inline select,
.form-horizontal select,
.form-search .help-inline,
.form-inline .help-inline,
.form-horizontal .help-inline,
.form-search .uneditable-input,
.form-inline .uneditable-input,
.form-horizontal .uneditable-input,
.form-search .input-prepend,
.form-inline .input-prepend,
.form-horizontal .input-prepend,
.form-search .input-append,
.form-inline .input-append,
.form-horizontal .input-append {
  display: inline-block;
  *display: inline;
  margin-bottom: 0;
  *zoom: 1;
}
  • simple_form, , f.input. , , , input_html , f.input, . , f.input , div.

, twitter bootstrap , , div, , , - .

, , .form-inline , ?

+1

All Articles