我有这个 simple_form
<%= 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
字段,它是我想要的每个状态的背景颜色的十六进制代码。知道如何将这个十六进制代码传递到每个背景标签颜色吗?!我已经尝试了几个小时。
最佳答案
你有没有试过像这样传递它......
# assuming "hex" is stored in the order model. Any variable should work
:label_html => { :style => "background-color:##{@order.hex};" }
如果没有,请回复您的结果
关于ruby-on-rails - collection_label 的 Simple_form 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9171226/