1

我一直在尝试将我的“记住我”复选框放在我的垂直表单中(使用 simple_form)

我得到了错误

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

config/initializers/simple_form_bootstrap.rb(我也试过把is放在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>

我无法弄清楚为什么它没有找到我的 config.wrapper ...

4

2 回答 2

2

要在不使用 config.wrappers 的情况下解决您的原始问题,您可以尝试执行以下操作:

f.input :remember_me, inline_label: true ...
于 2013-03-04T01:59:16.493 回答
0

我有同样的问题,通过将以下行添加到 'config/initializers/simple_form.rb' 来解决它

 <p> config.wrappers :checkbox, :tag => 'div', :class =>
 'control-group', :error_class => 'error' do |b|<br>   b.wrapper :tag
 => 'div', :class => 'controls' do |ba|<br>
     ba.use :label_input<br>   end<br> end </p>
于 2013-06-19T12:47:27.253 回答