I have the following code in my view:
<%= form_for :command_selected, :method => "get", :url => {:action => "command_domain_selected"} do |f| %>
<a> <%= link_to "Make Deployment", {:controller=>"authorization", :action => 'command_domain_selected',:id=>'make_deployment'}, :remote=> true %><br /></a>
<%= f.radio_button :domain, '1dev' %> <%= label :domain, '1dev'%><br />
<%= f.radio_button :domain, '2dev' %> <%= label :domain, '2dev'%><br />
<script type=text/javascript>
$('a').click(function(){ $('form').submit(); return false; });
</script>
<%end%>
When i click on the “Make Deployment” link in the above code, only the selected radio button is passed as the parameter to the command_domain_selected action in the controller. Please let me know how to pass the value of the hyperlink too.
Thank you
I added the following code too:
<%= link_to 'Make Deployment', "#", :onclick=>"$('.search_form').submit()" , :id => 'make_deployment'%>
But the parameters that are being passed are just the radio button values and not the hyperlink value
I’m with Yuri. Use a form (method get and it will all go in the URL). Then just style the button to look like a link if you’re that fussed!
Otherwise if you must continue with the hideousness add a hidden_field with the extra param you want to submit. Its not passing the hyperlink params because that has nothing to do with a form (unlike a submit button which does)