简单形式 w。 Bootstrap - 设置 "html5: true" 时输入变为 "form-inline"
SimpleForm w. Bootstrap - Input changes to "form-inline" when setting "html5: true"
我有一个基于时间的输入,我想将其显示为一个输入与两个默认选择框。我发现解决方案是将 html: true
添加到我的输入中。不幸的是,这会将输入的父容器 class 从 form-control
更改为 form-inline
。有没有一种方法可以从 SimpleForm 中更改它,而无需在 html 选项哈希中明确地给它 class?
转到 simple_form_bootstrap.rb 并检查此片段
config.wrappers :multi_select, tag: :div, class: 'form-group', error_class: 'has-danger' do |b|
b.use :html5
b.optional :readonly
b.use :label
b.wrapper tag: :div, class: 'form-inline' do |ba|
ba.use :input, class: 'form-control'
ba.use :error, wrap_with: { tag: :div, class: 'invalid-feedback' }
ba.use :hint, wrap_with: { tag: :small, class: 'form-text text-muted' }
end
end
有您要查找的内联表单,请注意时间和日期的默认包装器是 multi_select
config.wrapper_mappings = {
check_boxes: :horizontal_radio_and_checkboxes,
radio_buttons: :horizontal_radio_and_checkboxes,
file: :horizontal_file_input,
boolean: :horizontal_boolean,
datetime: :multi_select,
date: :multi_select,
time: :multi_select
}
我有一个基于时间的输入,我想将其显示为一个输入与两个默认选择框。我发现解决方案是将 html: true
添加到我的输入中。不幸的是,这会将输入的父容器 class 从 form-control
更改为 form-inline
。有没有一种方法可以从 SimpleForm 中更改它,而无需在 html 选项哈希中明确地给它 class?
转到 simple_form_bootstrap.rb 并检查此片段
config.wrappers :multi_select, tag: :div, class: 'form-group', error_class: 'has-danger' do |b|
b.use :html5
b.optional :readonly
b.use :label
b.wrapper tag: :div, class: 'form-inline' do |ba|
ba.use :input, class: 'form-control'
ba.use :error, wrap_with: { tag: :div, class: 'invalid-feedback' }
ba.use :hint, wrap_with: { tag: :small, class: 'form-text text-muted' }
end
end
有您要查找的内联表单,请注意时间和日期的默认包装器是 multi_select
config.wrapper_mappings = {
check_boxes: :horizontal_radio_and_checkboxes,
radio_buttons: :horizontal_radio_and_checkboxes,
file: :horizontal_file_input,
boolean: :horizontal_boolean,
datetime: :multi_select,
date: :multi_select,
time: :multi_select
}