是否可以覆盖 SimpleForm 生成的表单字段的基础 "class"?

Is it possible to override the base "class" of SimpleForm generated form fields?

这是我的 simple_form.rb :

  config.wrappers :select_form, tag: "div", class: "control" do |b|
    b.use :html5
    b.use :placeholder
    b.optional :pattern
    b.optional :readonly
    b.use :label, class: "label"
    b.use :input, wrap_with: { tag: "div", class: "select" }
    b.use :full_error, wrap_with: { tag: "div", class: "help is-danger" }
    b.use :hint, wrap_with: { tag: "small", class: "form-text text-muted" }
  end

生成这个:

<div class="control select required user_role"><label class="label select required" for="user_role">User Role</label>
    <div class="select"><select class="select required" required="required" aria-required="true" name="user[role]" id="user_role">

问题是 SimpleForm 和我的 CSS class Bulma 都使用 class .select 来确定元素的类型,导致图形冲突。

有没有必要从父 <div> 中删除 class select,因为它不是必需的?

将此添加到我的 initializers/simple_form.rb :

class SimpleForm::Wrappers::Many
  def wrap(input, options, content)
    return content if options[namespace] == false
    return if defaults[:unless_blank] && content.empty?

    tag = (namespace && options[:"#{namespace}_tag"]) || @defaults[:tag]
    return content unless tag

    klass = html_classes(input, options)

    opts  = html_options(options)

    # Removes the conflict class ".select" from the wrapper
    klass.delete(:select) if options[:wrapper] == :select_form && klass.length > 1
    opts[:class] = (klass << opts[:class]).join(' ').strip unless klass.empty?
    input.template.content_tag(tag, content, opts)
  end
end