Search code examples
formsruby-on-rails-4link-to

Link_to Parameter to send form


I have one page that list sub agents lists, if the user press link_to link, it will send to another page which is form, so user can create money transactions for sub agent

the problem is I have to refresh page that have form before the user can press submit, if I not refresh the page, pressing submit button it's not doing anything

below is subagent link, since I'm using bootstrap and the next page has ransack parameter

        <%= link_to '<i class="glyphicon glyphicon-transfer"></i>'.html_safe, new_paymentformandira_path( :q => {"id_subagent_eq"=>subagent.id_subagent} ) , :class => 'btn btn-mini btn-info' %>

Below is the form that I have to refresh before I can send it it has 3 part (since it's partial)

            <%= form_tag create_payment_paymentformandiras_path, :method => :put do %>
                <% @receivablelists.each do |receivablelist|  %>
                     <tr class="row-detail">
                        <% if receivablelist.booking_date %>
                            <td><%= receivablelist.booking_date.strftime("%e %B %Y") %></td>
                        <% else  %>
                            <td></td>
                        <% end  %>
                        <td><%= link_to receivablelist.guest_name, edit_booking_path(receivablelist.id) %></td>
                        <td><%= receivablelist.city %></td>
                        <td><%= receivablelist.hotel_name %></td>
                        <td><%= receivablelist.sub_agent %></td>
                        <td><%= receivablelist.invoice_mandira %></td>
                        <td class="text-right"> <%= number_with_precision(receivablelist.total_pay_debt_count , precision: 2, separator: '.', delimiter: ',') %></td>


                        <td><%= check_box_tag 'include_payment[]', position,false, class: "transfer-include" %>  </td>
                        <% position = position + 1 %>

                        <td><%= text_field_tag 'text_payment_amount[]', receivablelist.total_pay_debt_count, class: 'transfer-amount right-align' %></td>
                        <%= hidden_field_tag 'text_id[]', receivablelist.id %>
                    </tr>
                <% end  %>
                <h3 class="text-info">Payment</h3>
                <div class="row">
                    <div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
                        <p>Transfer Date</p>
                        <p>Destination Bank Name</p>
                        <p>Notes</p>
                        <p>Total Deposit / transfer</p>
                        <p>Total pay</p>
                    </div>
                    <div class="col-xs-9 col-sm-9 col-md-9 col-lg-9">
                        : <%= text_field 'text_transfer_date',"", :class => :datepicker %> <br>
                        : <%= text_field 'text_bank_name',"" %> <br> 
                        : <%= text_field 'text_notes',"" %> <br>
                        : <%= text_field 'text_total_deposit', nil, class: "text-right" %><br>
                        : <%= text_field_tag 'text_total_amount', nil,  class: "total-transfer-amount text-right text-muted", disabled: true, size: 12 %><br>
                    </div>
                </div>
                <%= submit_tag "Do Payment" %>

Thank you


Solution

  • I just solve my problem above, referenced from this link Submit button does not work unless I refresh the page form_for Rails

    it's mismatched tag between table and form tag

    hopefully it can help others