【发布时间】:2016-07-21 09:20:36
【问题描述】:
我有一个允许用户拒绝或批准记录的表单。我试图设计它,所以每行都有一个拒绝复选框和一个批准复选框。在底部有两个按钮拒绝和再次批准。当用户检查批准一个并拒绝另一个,然后按下其中一个按钮拒绝或批准该
我最初希望能够有一个按钮流程,它会知道何时单击批准的记录,它将传递给批准路径,如果选择拒绝路径,它也会知道将这些值传递给拒绝路径。
以下是我目前的代码,但我不确定如何继续以及这是否可能;
.block-body
%table.table.table-striped.sla
%thead
%tr.medium
%th Campaign
%th Status
%th Approve
%th Reject
%th.notes{:style => "display: none"} Rejection Reason (Required)
%tbody
= form_for :campaign do |f|
- if @campaigns == nil
= @campaigns.inspect
- else
- @campaigns.each do |campaign|
%tr.medium
%td= campaign.name
%td= campaign.status
%td
-if ["New", "Updated"].include? campaign.status #-if campaign.status != "Approved"
= f.check_box :status, {id: "#{campaign.id}", :class => "approvedservices"}, "Approved"
%td{:style => "width:100px;"}
-unless ["Rejected", "Approved"].include? campaign.status
= f.check_box :status, {id: "reject#{campaign.id}", :class => "rejectedservices"}, "Rejected"
%td.notes{:style => "display: none"}
%input{:style => "display: none", :id => "notesrow_#{campaign.id}", :type => "text"}
%tr.medium
%td.white{:colspan => 2}
%td.white{:style => "width:100px;"}
= submit_tag "First Button", :name => 'first_button'
%td.white{:style => "width:100px;"}
= submit_tag "Second Button", :name => 'second_button'
【问题讨论】:
标签: ruby-on-rails forms