[英]Customizing simple_form boolean input
要將一些標記添加到布爾輸入(復選框),我試圖創建一個這樣的自定義輸入:
class BooleanWithIconInput < SimpleForm::Inputs::BooleanInput
def input(wrapper_options)
super
end
end
問題在於,此輸入已經以不同的方式顯示,因為它缺少<div class="checkbox">
容器,並且添加了諸如control_label
和form_control
類的類。
為什么會發生這種情況,我如何獲得相同的行為?
在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
我知道這只是一個簡單的提示。 不幸的是,我現在無法提供定制解決方案。 希望能幫助到你。 我稍后可能會對此有更深入的了解...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.