Html 自定义简单形式布尔输入
要将一些标记添加到布尔输入(复选框),我尝试创建如下自定义输入:Html 自定义简单形式布尔输入,html,ruby-on-rails,ruby,simple-form,Html,Ruby On Rails,Ruby,Simple Form,要将一些标记添加到布尔输入(复选框),我尝试创建如下自定义输入: class BooleanWithIconInput < SimpleForm::Inputs::BooleanInput def input(wrapper_options) super end end class BooleanWithIconInput
class BooleanWithIconInput < SimpleForm::Inputs::BooleanInput
def input(wrapper_options)
super
end
end
class BooleanWithIconInput
问题是,此输入的显示方式已经不同,因为它缺少一个
容器,并且添加了control\u label
和form\u control
之类的类
为什么会发生这种情况,我如何才能获得相同的行为?在
初始化器/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
如果这对您没有帮助,简单表单文档中有一些关于如何个性化标记的详细文档
我知道这只是一个简单的提示。不幸的是,我现在无法帮助定制解决方案。希望能有帮助。稍后我可能会对此有更深入的了解