将id添加到表单,rails

时间:2013-07-21 22:06:22

标签: ruby-on-rails ruby-on-rails-3

我有问题将id =“my-form”添加到我的表单中:

<tr>
<%= form_for([@patient, @patient.treatments.build], :id => "my_form") do |f|%>
<th><%= f.collection_select :category_id, Category.find(:all), :id, :typ %></th>
<th><%= f.text_field :content , :id => "inputbox"%></th>
<th><%= f.text_field :day, :value => Date.today %></th>
<th><%= f.submit  :class => 'btn btn-small btn-primary searsa'%></th>
<% end %>
</tr>

你会怎么做?我也尝试过:

<%= form_for, :id => "my_form"([@patient, @patient.treatments.build]) do |f|%>

1 个答案:

答案 0 :(得分:2)

请尝试:

<%= form_for([@patient, @patient.treatments.build], :html => { :id => "my_form" }) do |f|%>