SimpleForm w。 Bootstrap - 输入更改为" form-inline"设置" html5:true"

时间:2017-09-28 01:51:53

标签: ruby-on-rails twitter-bootstrap simple-form

我有一个基于时间的输入,我想显示为一个输入与两个默认选择框。我发现解决方法是在我的输入中添加html: true。不幸的是,这会将输入的父容器类从form-control更改为form-inline。有没有办法在SimpleForm中更改它,而没有在html选项哈希中明确地给它类?

1 个答案:

答案 0 :(得分:0)

转到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
}