Ruby 简单形式的自定义包装器:重复输入
我正在Rails 5.2应用程序中使用。目前,我在使用我的输入时遇到了一些问题 我的包装纸 我的表格 (@user)do | f的Ruby 简单形式的自定义包装器:重复输入,ruby,ruby-on-rails-5,simple-form,Ruby,Ruby On Rails 5,Simple Form,我正在Rails 5.2应用程序中使用。目前,我在使用我的输入时遇到了一些问题 我的包装纸 我的表格 (@user)do | f的simple_form_| ... ... 终止 预期产量 …实际产量 我在想我的包装器配置中可能有错误,我现在无法找到它。正如我的一位朋友所指出的,解决方案是在包装器配置中使用label而不是label\u input config.wrappers :mini_input, tag: 'div', class: 'row responsive-label
simple_form_|
...
...
终止
预期产量
…实际产量
我在想我的包装器配置中可能有错误,我现在无法找到它。正如我的一位朋友所指出的,解决方案是在包装器配置中使用
label
而不是label\u input
config.wrappers :mini_input, tag: 'div', class: 'row responsive-label', error_class: 'error' do |b|
b.use :html5
b.wrapper tag: 'div', class: 'col-sm-12 col-md-3' do |c|
# c.use :label_input Wrong
c.use :label
end
b.wrapper tag: 'div', class: 'col-sm-12 col-md-4' do |c|
c.use :input
end
end
我喜欢这个答案哈哈:P
simple_form_for(@user) do |f|
...
<%= f.input :name, required: true, label: "Name", autofocus: true, wrapper: :mini_input %>
...
end
<div class="row responsive-label">
<div class="col-sm-12 col-md-3">
<label ...>
</div>
<div class="col-sm-12 col-md-4">
<input ...>
</div>
</div>
<div class="row responsive-label">
<div class="col-sm-12 col-md-3">
<label ...>
<input ...> <!-- This input should not be here -->
</div>
<div class="col-sm-12 col-md-4">
<input ...>
</div>
</div>
config.wrappers :mini_input, tag: 'div', class: 'row responsive-label', error_class: 'error' do |b|
b.use :html5
b.wrapper tag: 'div', class: 'col-sm-12 col-md-3' do |c|
# c.use :label_input Wrong
c.use :label
end
b.wrapper tag: 'div', class: 'col-sm-12 col-md-4' do |c|
c.use :input
end
end