hidden_field_tag
- 1.0.0 (0)
- 1.1.6 (0)
- 1.2.6 (0)
- 2.0.3 (38)
- 2.1.0 (0)
- 2.2.1 (0)
- 2.3.8 (0)
- 3.0.0 (0)
- 3.0.9 (-2)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (4)
- 7.1.3.4 (0)
- 7.2.3 (0)
- 8.0.0 (0)
- 8.1.1 (0)
- What's this?
hidden_field_tag(name, value = nil, options = {})
public
Creates a hidden form input field used to transmit data that would be lost due to HTTP’s statelessness or data that should be hidden from the user.
Options
-
Creates standard HTML attributes for the tag.
Examples
hidden_field_tag 'tags_list' # => <input type="hidden" name="tags_list" id="tags_list" autocomplete="off" /> hidden_field_tag 'token', 'VUBJKB23UIVI1UU1VOBVI@' # => <input type="hidden" name="token" id="token" value="VUBJKB23UIVI1UU1VOBVI@" autocomplete="off" /> hidden_field_tag 'collected_input', '', onchange: "alert('Input collected!')" # => <input type="hidden" name="collected_input" id="collected_input" value="" onchange="alert('Input collected!')" autocomplete="off" />
Storing array values
I tried to add a array value using hidden_field_tag and access it in jquery. It just returns the flattened version of array. eg:(If i try to store [1,[1,2,3]] in hidden_field_tag , in jquery iam just getting ‘1 1 2 3’) but if i use input field with type=hidden iam getting the correct value. Why is that?
Rails 3.2.19
As Jebin reported, we are not getting the value in array format when we set the hidden_field_tag with an Array variable, instead it is a String that we are getting.

