2012-02-07 21 views
0

我有這個simple_formSimple_form風格collection_label的

<%= simple_form_for(@order) do |f| %> 
        <%= f.error_notification %> 
        <%= f.association :orderstatus, :label => false, :include_blank => false, :input_html => { :class => 'order-status' } , :as => :radio, :label_html => { :style => "background-color:black;" } %> 
        <%= f.button :submit, :value => 'Update', :class => 'button grey small' %> 

       <% end %> 

,它創造這樣的:http://d.pr/9Bqd在數據庫中,我也有一個字段color這是背景色我想每個狀態的十六進制代碼。任何想法如何將這個十六進制代碼傳遞到每個背景標籤的顏色?我試了幾個小時。

回答

0

您是否嘗試過在傳遞這樣的...

# assuming "hex" is stored in the order model. Any variable should work 
:label_html => { :style => "background-color:##{@order.hex};" } 

如果沒有,請與您的響應結果