我有我的表单标签,我的表单中还有两个按钮。我如何在单击提交按钮时在我的表单中调用不同的操作。
这是我的代码:
<%= form_for :attachment_metadata, :url=>{:action=>'delete_files'}, :html=>{:onsubmit=> "return confirm('Are you sure, you want to delete selected files?');",:multipart => true} do |f| %>
<table>
..........Some stuff here..........
</table>
<%= submit_tag 'Reprocess', :class =>'button' %>
<%= submit_tag 'Remove', :class =>'button' %>
<% end %>
单击“重新处理”时,我想调用不同的操作,但形式相同。
我该怎么做?
请帮忙
提前致谢
最佳答案
params[:commit]
可以区分两个提交标签的 Action 。
更新:
@action = params[:commit]
如果您单击 Reprocess
按钮并给出“Remove
”,它会将 @action
值作为“Reprocess
” "值,如果您单击 Remove
按钮,
关于mysql - 如何在两个提交标签上提及表单中的不同操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15608959/