【发布时间】:2014-08-20 09:10:39
【问题描述】:
所以这就是我想做的:
<% for x in 6..10 %>
<%= form_for(current_user.responses.new, html:{class: 'col-xs-2 col-md-1 col-lg-1 vcenter center'}) do |f, index| %>
<%= f.text_field :response_value, label: false, :class => "my-width <%= x %>" %>
<% end %>
<% end %>
但它不起作用。我想在输入字段上有两个类,一个是使用 html 的普通 css 类。另一个使用 erb 变量,在本例中为“x”。
我试过了
<%= f.text_field :response_value, label: false, :class => "my-width center vcenter", :class => x %>
仅分配第二个:class,并覆盖第一个。
如何将这两个类(“my-width”和 x)分配给表单输入字段?
【问题讨论】:
标签: css ruby-on-rails forms