2017-02-02 33 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

我知道这只是一个简单的提示。不幸的是,我现在无法用自定义解决方案来帮忙。希望能帮助到你。我可能会稍后再深入...