Reputation: 570
I am using jQuery to assign a value to a hidden field:
$('#hidden_id').val("ABC");
In my View, I have:
<%= hidden_field_tag(:id => "hidden_id", :val => "") %>
How do I pass the value "ABC" from the form to to my Controller (through the param ":val")?
Upvotes: 2
Views: 1499
Reputation: 1904
You should be defining your hidden_field_tag like this
<%= hidden_field_tag 'hidden', '', id: 'hidden_id' %>
equivalent to
<input type="hidden" name="hidden" id="hidden_id" value="">
take a look at the documentation for help.
Upvotes: 3