ruby-on-railsruby-on-rails-3twitter-bootstrapsimple-form

simple_form config wrapper not found


I've been trying to put my 'remember me' checkbox in line in my vertical form (using simple_form)

and I am getting the error

ActionView::Template::Error (Couldn't find wrapper with name inline_checkbox):

config/initializers/simple_form_bootstrap.rb (I have also tried putting is in simple_form.rb)

  config.wrappers :inline_checkbox, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
  b.use :html5
  b.use :placeholder
  b.wrapper :tag => 'div', :class => 'controls' do |ba|
    ba.wrapper :tag => 'label', :class => 'checkbox' do |bb|
      bb.use :input
      bb.use :label_text
    end
    ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
    ba.use :hint,  :wrap_with => { :tag => 'p', :class => 'help-block' }
  end
end

newform.html.erb

<div class="row">
    <div class="span4">
        <%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), html: {class: "well"}) do |f| %>

        <fieldset>
          <legend>Log In</legend>
          <%= f.input :email %>
          <%= f.input :password %>

          <% if devise_mapping.rememberable? -%>
            <div ><%= f.input :remember_me, :wrapper => :inline_checkbox, as: :boolean %> 
          <% end -%></div>

          <div><%= f.button :submit, "Log in" %></div>
        </fieldset>
        <% end %>

        <%= render "devise/shared/links" %>
    </div>

    <div class="span8">
    </br>
        <h2>Logging in is easy and secure </h2>
    </div>
</div>

I can't work out why it's not finding my config.wrapper...


Solution

  • To solve your original issue without doing anything with config.wrappers, you could try doing:

    f.input :remember_me, inline_label: true ...