2012-02-07 19 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};" } 

如果没有,请与您的响应结果