ruby-on-rails 未找到simple_form配置 Package

g6baxovj  于 2022-12-15  发布在  Ruby
关注(0)|答案(2)|浏览(128)

我一直在尝试把我的“记住我”复选框在我的垂直形式行(使用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...

yuvru6vn

yuvru6vn1#

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

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

9jyewag02#

我遇到了同样的问题,通过在“config/initializers/simple_form.rb”中添加以下行解决了这个问题

config.wrappers :checkbox, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
   b.wrapper :tag => 'div', :class => 'controls' do |ba|
     ba.use :label_input
   end
end

相关问题