【发布时间】:2013-07-20 10:51:50
【问题描述】:
基本上我在这里遇到@user1224344 之类的问题:
How to submit multiple, duplicate forms from same page in Rails - preferably with one button
第一个答案看起来很不错,但我作为 Rails 初学者在我的项目中转置它时遇到问题。好的,我有两个具有相同控制器的表单,应该只用一个提交按钮保存:
<table width="100%">
<tr>
<%= form_for([@patient, @patient.treatments.build]) do |f| %>
<th><%= f.collection_select :category_id, Category.find(:all), :id, :typ %></th>
<th><%= f.text_field :content %></th>
<th><%= f.hidden_field :note, :id => "canvascontent" %></th>
<th><%= f.text_field :day, :value => Date.today %></th>
<th><%= f.submit :class => 'btn btn-small btn-primary', :onclick => "sketch.toDataURL()" %></th>
<th><input type="button" onclick="sketch.clearRecording()" class="btn btn-small btn-danger" value="Löschen"></th>
<% end %>
</tr>
</table>
<table width="100%">
<tr>
<%= form_for([@patient, @patient.treatments.build]) 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'%></th>
<% end %>
</tr>
</table>
感谢您的帮助!特别是在周日晚上(至少在德国)
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3