我有这个collection_radio_buttons字段已经定制了一点以显示图标,但现在由于某种原因错误范围标记不再显示。此外,我想摆脱每个输入本身周围的标签包装。也许我必须在初始化文件中创建一个自定义块?或者我可能在街区遗漏了一些东西?
这是我的代码
= f.simple_fields_for :answer_raiting do |builder|
= builder.collection_radio_buttons(:response, AnswerRaiting::RAITING, :first, :last,
collection_wrapper_tag: :div, collection_wrapper_class: "form-group radio-stars",
item_wrapper_tag: false) do |b|
= b.radio_button + fa_icon("star-o")
答案 0 :(得分:0)
1)您可以使用.error
中的builder
方法:
builder.error :response
2)让我们看看使用collection_radio_buttons method
时会发生什么:
def collection_radio_buttons(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
SimpleForm::Tags::CollectionRadioButtons.new(@object_name, method, @template, collection, value_method, text_method, objectify_options(options), @default_options.merge(html_options)).render(&block)
end
要跳过每个项目的包装,您可以传递item_wrapper_tag: nil
选项。
要摆脱包装,你可以阅读this docs. 阅读custom components。