2017-02-02 67 views
0

要一些標記添加到一個布爾輸入(複選框),我想創建這樣的自定義輸入:定製simple_form布爾輸入

class BooleanWithIconInput < SimpleForm::Inputs::BooleanInput 
    def input(wrapper_options) 
    super 
    end 
end 

的問題是,這個輸入已經顯示有所不同,因爲它缺少一個<div class="checkbox">容器,它添加了類似control_labelform_control

爲什麼會發生這種情況,我該如何獲得相同的行爲?

回答

1

initializers/simple_form.rb文件你已經可以做一些調整:例如默認是

# Define the way to render check boxes/radio buttons with labels. 
    # Defaults to :nested for bootstrap config. 
    # inline: input + label 
    # nested: label > input 
    config.boolean_style = :nested 
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. 
    # config.collection_wrapper_tag = nil 
    # You can wrap each item in a collection of radio/check boxes with a tag, 
    # defaulting to :span. 
    # config.item_wrapper_tag = :span 

如果這沒有幫助你的simple_form文檔有關於如何個性化標記一些詳細的文檔。

https://github.com/plataformatec/simple_form

我知道這只是一個簡單的提示。不幸的是,我現在無法用自定義解決方案來幫忙。希望能幫助到你。我可能會稍後再深入...