我一直试图将我的“记住我”复选框放在我的垂直形式中(使用simple_form)
我收到了错误
ActionView::Template::Error (Couldn't find wrapper with name inline_checkbox):
config / initializers / simple_form_bootstrap.rb(我也试过把put放在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 ......
答案 0 :(得分:2)
要解决原始问题而不对config.wrappers做任何事情,您可以尝试:
f.input :remember_me, inline_label: true ...
答案 1 :(得分: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>