Vijay Chouhan
Vijay Chouhan

Reputation: 4883

How to get params value in action on link click

My view code is

<%= form_for(@payment,:url => verify_payment_payment_index_path) do |f| %>
  <%= f.radio_button("amount", "10") %>
  <%= label :amount, '10 Rs',:style => "display:inline" %> <br>
  <%= f.radio_button("amount", "20") %>
  <%= label :amount, '20 rs',:style => "display:inline" %><br>
  <%= f.radio_button("amount", "50") %>
  <%= label :amount, '50 rs',:style => "display:inline" %><br>
  <%= f.radio_button :amount, '100' %> 
  <%= label :amount, '100 rs',:style => "display:inline" %><br>    
  <%= link_to "Make Payment", verify_payment_payment_index_url, 
              :class => "btn",
              :data => { :toggle => "modal",
                         "target" => "#myBox" },
              "for"=>"Make Payment" %>

<% end %>

And I want to access all values in params in controller action after click on link "Make Payment". So how can I achieve it in rails 3?. Please note that I have to open lightbox on click of link and then submit form

Upvotes: 0

Views: 124

Answers (1)

ernd enson
ernd enson

Reputation: 1764

you need to submit the form! so try the following:

<%= form_for(@payment,:url => verify_payment_payment_index_path) do |f| %>
   <%= f.radio_button("amount", "10") %>
   <%= label :amount, '10 Rs',:style => "display:inline" %> <br>
   <%= f.radio_button("amount", "20") %>
   <%= label :amount, '20 rs',:style => "display:inline" %><br>
   <%= f.radio_button("amount", "50") %>
   <%= label :amount, '50 rs',:style => "display:inline" %><br>
   <%= f.radio_button :amount, '100' %> 
   <%= label :amount, '100 rs',:style => "display:inline" %><br>

   <%= f.submit "Make Payment", :class=>"btn",:data => {:toggle => "modal","target"=>"#myBox"},"for"=>"Make Payment" %>

<% end %>

Upvotes: 1

Related Questions