2016-12-09 22 views
-1

我有這個collection_radio_buttons字段已定製了一下顯示圖標,但現在由於某種原因,錯誤跨度標記不再顯示。另外我想擺脫每個輸入本身的標籤封裝。也許我將不得不在初始化文件中創建一個自定義塊?或者我可能在塊中丟失了某些東西?簡單的窗體引導自定義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

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

+0

我看了一下自定義組件,但這裏的問題是輸入本身內置有標籤的包裝 – adavia

+0

item_wrapper_tag:無不會刪除標籤輸入包裝 – adavia

+0

@adavia嘗試使用'boolean_style:inline'選項 –