I'm using check_box but I'm not married to it, probably because I don't understand it. Basically, I am presenting a list of upcoming payments and I want to select which items are to be paid...
<% form_for :supptrans, @supptrans, :url => { :action => "accept_checks" } do |form| %> <% odd_or_even = 0 for check_due in @supptrans odd_or_even = 1 - odd_or_even %> <tr valign="top" class="ListLine<%= odd_or_even %>"> <td><%= check_box("check_due", "print_check") %></td> <td><%=h (check_due.supplier.suppname) %></td> <td><%=h (check_due.suppreference) %></td> <td><%= check_due.duedate.to_s.split('-')[1].to_s + "-" + check_due.duedate.to_s.split('-')[2].to_s + "-" + check_due.duedate.to_s.split('-')[0].to_s %></td> <td align="right"><%= check_due.ovamount.to_fl(2) %></td> </tr> <% end %> <%= submit_tag 'Print Checks' %><% end %>
and when I checked 3 different boxes, I see in a <%= debug params %> only the first line item is returned...
--- !map:HashWithIndifferentAccess check_due: !map:HashWithIndifferentAccess print_check: "0" commit: Print Checks authenticity_token: HqDnPuefppjsMYQhZwAq0akBrQTfnvIKrHciv81aKe0= action: accept_checks controller: payables
and it returns a value of '0' because it was unchecked.
I was hoping that it would return each line item that was checked or all of the line items and I could loop through them and discard the unchecked items but I only get the first value, nothing else.
How can I accomplish this?
Craig