2013-09-22 41 views

回答

0

你可以嘗試使用member_label選項

正如你可以調用一個Proc它你可以簡單地設置PROC返回什麼,或者如果你想的明星還有,返回一個明星...

https://github.com/justinfrench/formtastic/wiki/4.1-Options-Cheat-Sheet

+0

哇!使用member_label實現該功能會很好,現在將試用 – Muntasim

+0

Option **:member_label ** *已被棄用*。這個[pull request](https://github.com/justinfrench/formtastic/pull/1094)解釋了你應該使用什麼。 – yesnik

0

我在一段時間後得到了解決方案。

在這裏,我願把對他人的解決方案:

<%= f.input :star_rating, as: :radio, collection: (1..5).collect { |c| ['', c, {:disabled => c <=2, title: "#{c} star"}] } %> 

爲了讓明星的圖像作爲標籤:(我用SASS)

#hotel_star_rating_input li.choice { 
    float: left; 
    width: 30px; 

    label { 
    height: 25px; 
    background: url('star.png') no-repeat 2px bottom; 

    } 
} 
0

您可以通過空字符串作爲標籤收集選項:

f.input :star_rating, 
     as: :radio, 
     label: false, 
     collection: [['', 1], ['', 2], ['', 3], ['', 4], ['', 5]] 

,這會使得拉迪o沒有標籤的按鈕。