2012-07-21 22 views
1

我使用SimpleForm並能夠創建無線電列表。有沒有一種方法可以將它們渲染爲按鈕或圖像?將無線電渲染爲按鈕/圖像simple_form

我做了一些搜索和嘗試這樣做:

- f.collection_radio_buttons(:category, [['Male', 'icon_male'], ['Female', 'icon_female']], :first, :last) do |category| 
    = category.label { image_tag("/assets/icons/16x16/#{category.text}.png") + category.radio_button } 

但是,它仍然呈現單選圖標,請參見下面

enter image description here

有沒有一種方法,以使其像剛纔的圖像,是可選或類似於Twitter Bootstrap按鈕的按鈕? http://twitter.github.com/bootstrap/javascript.html#buttons

而且,這需要我指定視圖圖像列表,我需要它來趕走模型,像category.image_url

+0

你可能會發現[這個答案](http://stackoverflow.com/a/11267138/1478467)有趣。儘管需要一點JS。 – Sherbrow 2012-07-21 21:47:01

回答

0

我結束了不使用simple_form的無線電元件。我只是訴諸jQuery和一個隱藏的輸入元素。